Remove deprecated functions

This commit is contained in:
Makis Maropoulos 2016-07-13 14:05:32 +03:00
parent e0ebc84bfe
commit f7a782b692
6 changed files with 18 additions and 140 deletions

View File

@ -11,12 +11,12 @@
- `config.Render/config.Render.Rest/config.Render.Template` -> **Removed**
- `config.Render.Rest` -> `rest.Config`
- `config.Render.Template` -> `$TEMPLATE_ENGINE.Config` except Directory,Extensions, Assets, AssetNames,
- `config.Render.Template.Directory` -> `iris.UseEngine($TEMPLAET_ENGINE.New()).Directory("./templates", ".html")`
- `config.Render.Template.Assets` -> `iris.UseEngine($TEMPLAET_ENGINE.New()).Directory("./templates",".html").Binary(assetFn func(name string) ([]byte, error), namesFn func() []string)`
- `config.Render.Template.Directory` -> `iris.UseTemplate($TEMPLAET_ENGINE.New()).Directory("./templates", ".html")`
- `config.Render.Template.Assets` -> `iris.UseTemplate($TEMPLAET_ENGINE.New()).Directory("./templates",".html").Binary(assetFn func(name string) ([]byte, error), namesFn func() []string)`
- `context.ExecuteTemplate` -> **Removed**, you can use the `context.Response.BodyWriter()` to get its writer and execute html/template engine manually, but this is useless because we support the best support for template engines among all other (golang) web frameworks
- **Added** `config.Server.ReadBufferSize & config.Server.WriteBufferSize` which can be passed as configuration fields inside `iris.ListenTo(config.Server{...})`, which does the same job as `iris.Listen`
- **Added** `iris.UseEngine($TEMPLAET_ENGINE.New()).Directory("./templates", ".html")` to register a template engine, now iris supports multi template engines, each template engine has its own file extension, no big changes on context.Render except the last parameter:
- **Added** `iris.UseTemplate($TEMPLAET_ENGINE.New()).Directory("./templates", ".html")` to register a template engine, now iris supports multi template engines, each template engine has its own file extension, no big changes on context.Render except the last parameter:
- `context.Render(filename string, binding interface{}, layout string{})` -> `context.Render(filename string, binding interface{}, options ...map[string]interface{}) | context.Render("myfile.html", myPage{}, iris.Map{"gzip":true,"layout":"layouts/MyLayout.html"}) |`
E-book and examples are not yet updated, no big changes.

View File

@ -22,7 +22,7 @@ func main() {
c.JSON(iris.StatusOK, iris.Map{
"Name": "Iris",
"Born": "13 March 2016",
"Stars": 4262,
"Stars": 4270,
})
})
iris.Listen(":8080")
@ -158,7 +158,7 @@ Todo
- [ ] Extend i18n middleware for easier and better internalization support
- [ ] Create a router as optional plugin, for optional path parts. Its name, 'ryan', taken from the community-member and donator who requested this feature
- [ ] Extend the iris control plugin
- [ ] Remove deprecated functions
- [x] Remove deprecated functions
- [ ] Will think more :)
> completed for release 'v3'

View File

@ -13,10 +13,6 @@ type (
// IContext the interface for the iris/context
// Used mostly inside packages which shouldn't be import ,directly, the kataras/iris.
IContext interface {
// deprecated Start
PostFormValue(string) string
PostFormMulti(string) []string
// deprecated End
Param(string) string
ParamInt(string) (int, error)
ParamInt64(string) (int64, error)

View File

@ -1,114 +0,0 @@
package iris
import "github.com/kataras/iris/config"
/* Contains some different functions of context.go & iris.go which will be removed on the next revision */
// SecondaryListen same as .AddServer/.Servers.Add(config.Server) instead
// DEPRECATED: use .AddServer instead
// AddServers starts a server which listens to this station
// Note that the view engine's functions {{ url }} and {{ urlpath }} will return the first's registered server's scheme (http/https)
//
// this is useful mostly when you want to have two or more listening ports ( two or more servers ) for the same station
//
// receives one parameter which is the config.Server for the new server
// returns the new standalone server( you can close this server by the returning reference)
//
// If you need only one server you can use the blocking-funcs: .Listen/ListenTLS/ListenUNIX/ListenTo
//
// this is a NOT A BLOCKING version, the main .Listen/ListenTLS/ListenUNIX/ListenTo should be always executed LAST, so this function goes before the main .Listen/ListenTLS/ListenUNIX/ListenTo
func SecondaryListen(cfg config.Server) *Server {
return Default.SecondaryListen(cfg)
}
// SecondaryListen same as .AddServer/.Servers.Add(config.Server) instead
// DEPRECATED: use .AddServer instead
// AddServers starts a server which listens to this station
// Note that the view engine's functions {{ url }} and {{ urlpath }} will return the first's registered server's scheme (http/https)
//
// this is useful mostly when you want to have two or more listening ports ( two or more servers ) for the same station
//
// receives one parameter which is the config.Server for the new server
// returns the new standalone server( you can close this server by the returning reference)
//
// If you need only one server you can use the blocking-funcs: .Listen/ListenTLS/ListenUNIX/ListenTo
//
// this is a NOT A BLOCKING version, the main .Listen/ListenTLS/ListenUNIX/ListenTo should be always executed LAST, so this function goes before the main .Listen/ListenTLS/ListenUNIX/ListenTo
func (s *Framework) SecondaryListen(cfg config.Server) *Server {
return s.Servers.Add(cfg)
}
// NoListen is useful only when you want to test Iris, it doesn't starts the server but it configures and returns it
// DEPRECATED: use ListenVirtual instead
// initializes the whole framework but server doesn't listens to a specific net.Listener
// it is not blocking the app
func NoListen(optionalAddr ...string) *Server {
return Default.NoListen(optionalAddr...)
}
// NoListen is useful only when you want to test Iris, it doesn't starts the server but it configures and returns it
// DEPRECATED: use ListenVirtual instead
// initializes the whole framework but server doesn't listens to a specific net.Listener
// it is not blocking the app
func (s *Framework) NoListen(optionalAddr ...string) *Server {
return s.ListenVirtual(optionalAddr...)
}
// CloseWithErr terminates all the registered servers and returns an error if any
// DEPRECATED: use Close instead, and if you want to panic on errors : iris.Must(iris.Close())
// if you want to panic on this error use the iris.Must(iris.Close())
func CloseWithErr() error {
return Default.Close()
}
// CloseWithErr terminates all the registered servers and returns an error if any
// DEPRECATED: use Close instead, and if you want to panic on errors : iris.Must(iris.Close())
// if you want to panic on this error use the iris.Must(iris.Close())
func (s *Framework) CloseWithErr() error {
return s.Close()
}
// MustUse registers Handler middleware to the beginning, prepends them instead of append
// DEPRECATED: use UseGlobal instead
// Use it when you want to add a global middleware to all parties, to all routes in all subdomains
// It can be called after other, (but before .Listen of course)
func MustUse(handlers ...Handler) {
Default.MustUse(handlers...)
}
// MustUseFunc registers HandlerFunc middleware to the beginning, prepends them instead of append
// DEPRECATED: use UseGlobalFunc instead
// Use it when you want to add a global middleware to all parties, to all routes in all subdomains
// It can be called after other, (but before .Listen of course)
func MustUseFunc(handlersFn ...HandlerFunc) {
Default.MustUseFunc(handlersFn...)
}
// MustUse registers Handler middleware to the beginning, prepends them instead of append
// DEPRECATED: use UseGlobal instead
// Use it when you want to add a global middleware to all parties, to all routes in all subdomains
// It can be called after other, (but before .Listen of course)
func (s *Framework) MustUse(handlers ...Handler) {
s.UseGlobal(handlers...)
}
// MustUseFunc registers HandlerFunc middleware to the beginning, prepends them instead of append
// DEPRECATED: use UseGlobalFunc instead
// Use it when you want to add a global middleware to all parties, to all routes in all subdomains
// It can be called after other, (but before .Listen of course)
func (s *Framework) MustUseFunc(handlersFn ...HandlerFunc) {
s.UseGlobalFunc(handlersFn...)
}
// PostFormMulti returns a slice of string from post request's data
// DEPRECATED: Plase use FormValues instead
func (ctx *Context) PostFormMulti(name string) []string {
return ctx.FormValues(name)
}
// PostFormValue This will be deprecated
///DEPRECATED: please use FormValueString instead
// PostFormValue returns a single value from post request's data
func (ctx *Context) PostFormValue(name string) string {
return ctx.FormValueString(name)
}

View File

@ -172,7 +172,7 @@ func TestMultiRunningServers_v1(t *testing.T) {
})
// start the secondary server
SecondaryListen(config.Server{ListeningAddr: "mydomain.com:80", RedirectTo: "https://" + host, Virtual: true})
AddServer(config.Server{ListeningAddr: "mydomain.com:80", RedirectTo: "https://" + host, Virtual: true})
// start the main server
go ListenTo(config.Server{ListeningAddr: host, CertFile: certFile.Name(), KeyFile: keyFile.Name(), Virtual: true})
// prepare test framework

28
iris.go
View File

@ -105,8 +105,8 @@ var (
//
// Note: it is a simple channel and decided to put it here and no inside HTTPServer, doesn't have statuses just true and false, simple as possible
// Where to use that?
// this is used on extreme cases when you don't know which .Listen/.NoListen will be called
// and you want to run/declare something external-not-Iris (all Iris functionality declared before .Listen/.NoListen) AFTER the server is started and plugins finished.
// this is used on extreme cases when you don't know which .Listen/.ListenVirtual will be called
// and you want to run/declare something external-not-Iris (all Iris functionality declared before .Listen/.ListenVirtual) AFTER the server is started and plugins finished.
// see the server_test.go for an example
Available chan bool
)
@ -144,11 +144,7 @@ type (
ListenVirtual(...string) *Server
Go() error
Close() error
// global middleware prepending, registers to all subdomains, to all parties, you can call it at the last also
// deprecated Start
MustUse(...Handler)
MustUseFunc(...HandlerFunc)
// deprecated End
UseTemplate(TemplateEngine) *TemplateEngineLocation
UseGlobal(...Handler)
UseGlobalFunc(...HandlerFunc)
OnError(int, HandlerFunc)
@ -239,7 +235,7 @@ func (s *Framework) initialize() {
}
// check and prepare the templates
if len(s.templates.engines) == 0 { // no template engine is registered, let's use the default
s.UseEngine(html.New())
s.UseTemplate(html.New())
}
s.templates.setReload(s.Config.IsDevelopment)
}
@ -489,15 +485,15 @@ s.renderer = &renderer{
contentType: s.Config.Render.Template.ContentType + "; " + s.Config.Render.Template.Charset,
}*/
// UseEngine adds a template engine to the iris view system
// UseTemplate adds a template engine to the iris view system
// it does not build/load them yet
func UseEngine(e TemplateEngine) *TemplateEngineLocation {
return Default.UseEngine(e)
func UseTemplate(e TemplateEngine) *TemplateEngineLocation {
return Default.UseTemplate(e)
}
// UseEngine adds a template engine to the iris view system
// UseTemplate adds a template engine to the iris view system
// it does not build/load them yet
func (s *Framework) UseEngine(e TemplateEngine) *TemplateEngineLocation {
func (s *Framework) UseTemplate(e TemplateEngine) *TemplateEngineLocation {
return s.templates.Add(e)
}
@ -506,7 +502,7 @@ func (s *Framework) UseEngine(e TemplateEngine) *TemplateEngineLocation {
// Use it when you want to add a global middleware to all parties, to all routes in all subdomains
// It can be called after other, (but before .Listen of course)
func UseGlobal(handlers ...Handler) {
Default.MustUse(handlers...)
Default.UseGlobal(handlers...)
}
// UseGlobalFunc registers HandlerFunc middleware to the beginning, prepends them instead of append
@ -514,7 +510,7 @@ func UseGlobal(handlers ...Handler) {
// Use it when you want to add a global middleware to all parties, to all routes in all subdomains
// It can be called after other, (but before .Listen of course)
func UseGlobalFunc(handlersFn ...HandlerFunc) {
Default.MustUseFunc(handlersFn...)
Default.UseGlobalFunc(handlersFn...)
}
// UseGlobal registers Handler middleware to the beginning, prepends them instead of append
@ -532,7 +528,7 @@ func (s *Framework) UseGlobal(handlers ...Handler) {
// Use it when you want to add a global middleware to all parties, to all routes in all subdomains
// It can be called after other, (but before .Listen of course)
func (s *Framework) UseGlobalFunc(handlersFn ...HandlerFunc) {
s.MustUse(convertToHandlers(handlersFn)...)
s.UseGlobal(convertToHandlers(handlersFn)...)
}
// OnError registers a custom http error handler