mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 10:41:03 +01:00
117 lines
5.4 KiB
Go
117 lines
5.4 KiB
Go
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) {
|
|
for _, r := range s.mux.lookups {
|
|
r.middleware = append(handlers, r.middleware...)
|
|
}
|
|
}
|
|
|
|
// 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.MustUse(convertToHandlers(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)
|
|
}
|