mirror of
https://github.com/kataras/iris.git
synced 2025-03-14 08:16:28 +01:00
Merge remote-tracking branch 'refs/remotes/origin/dev'
This commit is contained in:
commit
032cc01792
18
README.md
18
README.md
|
@ -139,10 +139,9 @@ I recommend writing your API tests using this new library, [httpexpect](https://
|
||||||
Versioning
|
Versioning
|
||||||
------------
|
------------
|
||||||
|
|
||||||
Current: **v3.0.0-pre.release**
|
Current: **v3.0.0**
|
||||||
> Iris is an active project
|
> Iris is an active project
|
||||||
|
|
||||||
|
|
||||||
Read more about Semantic Versioning 2.0.0
|
Read more about Semantic Versioning 2.0.0
|
||||||
|
|
||||||
- http://semver.org/
|
- http://semver.org/
|
||||||
|
@ -152,13 +151,20 @@ Read more about Semantic Versioning 2.0.0
|
||||||
|
|
||||||
Todo
|
Todo
|
||||||
------------
|
------------
|
||||||
> for the next release 'v3'
|
> for the next version 'v4'
|
||||||
|
|
||||||
|
- [ ] Refactor & extend view engine, separate the engines from the main code base, easier for the community to create new view engines.
|
||||||
|
- [ ] 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.
|
||||||
|
|
||||||
|
> completed for release 'v3'
|
||||||
|
|
||||||
- [x] [Dynamic/Wildcard subdomains](https://kataras.gitbooks.io/iris/content/subdomains.html)
|
- [x] [Dynamic/Wildcard subdomains](https://kataras.gitbooks.io/iris/content/subdomains.html)
|
||||||
- [x] [Create server & client side](https://kataras.gitbooks.io/iris/content/package-websocket.html) (js) library for .on('event', func action(...)) / .emit('event')... (like socket.io but supports only websocket)
|
- [x] [Create server & client side](https://kataras.gitbooks.io/iris/content/package-websocket.html) (js) library for .on('event', func action(...)) / .emit('event')... (like socket.io but supports only websocket)
|
||||||
- [x] [Create a view system](https://kataras.gitbooks.io/iris/content/render_templates.html) supporting different types of template engines
|
- [x] [Create a view engines system](https://kataras.gitbooks.io/iris/content/render_templates.html) supporting different types of template engines
|
||||||
- [x] Extend, test and publish to the public the [Iris' cmd](https://github.com/kataras/iris/tree/master/iris)[*](https://github.com/kataras/rizla)
|
- [x] Extend, test and publish to the public the [Iris' cmd](https://github.com/kataras/iris/tree/master/iris)[*](https://github.com/kataras/rizla)
|
||||||
- [ ] Complete the API tests, community can help also, tests are located [here](https://github.com/iris-contrib/tests).
|
- [x] Complete the API tests, community can help also, tests are located [here](https://github.com/iris-contrib/tests).
|
||||||
|
|
||||||
|
|
||||||
If you're **willing to donate** click [here](DONATIONS.md)!
|
If you're **willing to donate** click [here](DONATIONS.md)!
|
||||||
|
@ -185,7 +191,7 @@ License can be found [here](LICENSE).
|
||||||
[Travis]: http://travis-ci.org/kataras/iris
|
[Travis]: http://travis-ci.org/kataras/iris
|
||||||
[License Widget]: https://img.shields.io/badge/license-MIT%20%20License%20-E91E63.svg?style=flat-square
|
[License Widget]: https://img.shields.io/badge/license-MIT%20%20License%20-E91E63.svg?style=flat-square
|
||||||
[License]: https://github.com/kataras/iris/blob/master/LICENSE
|
[License]: https://github.com/kataras/iris/blob/master/LICENSE
|
||||||
[Release Widget]: https://img.shields.io/badge/release-v3.0.0--pre.release-blue.svg?style=flat-square
|
[Release Widget]: https://img.shields.io/badge/release-v3.0.0-blue.svg?style=flat-square
|
||||||
[Release]: https://github.com/kataras/iris/releases
|
[Release]: https://github.com/kataras/iris/releases
|
||||||
[Chat Widget]: https://img.shields.io/badge/community-chat-00BCD4.svg?style=flat-square
|
[Chat Widget]: https://img.shields.io/badge/community-chat-00BCD4.svg?style=flat-square
|
||||||
[Chat]: https://kataras.rocket.chat/channel/iris
|
[Chat]: https://kataras.rocket.chat/channel/iris
|
||||||
|
|
|
@ -78,6 +78,7 @@ var (
|
||||||
|
|
||||||
type (
|
type (
|
||||||
// Map is just a conversion for a map[string]interface{}
|
// Map is just a conversion for a map[string]interface{}
|
||||||
|
// should not be used inside Render when PongoEngine is used.
|
||||||
Map map[string]interface{}
|
Map map[string]interface{}
|
||||||
// Context is resetting every time a request is coming to the server
|
// Context is resetting every time a request is coming to the server
|
||||||
// it is not good practice to use this object in goroutines, for these cases use the .Clone()
|
// it is not good practice to use this object in goroutines, for these cases use the .Clone()
|
||||||
|
|
|
@ -68,6 +68,40 @@ func (s *Framework) CloseWithErr() error {
|
||||||
return s.Close()
|
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
|
// PostFormMulti returns a slice of string from post request's data
|
||||||
// DEPRECATED: Plase use FormValues instead
|
// DEPRECATED: Plase use FormValues instead
|
||||||
func (ctx *Context) PostFormMulti(name string) []string {
|
func (ctx *Context) PostFormMulti(name string) []string {
|
||||||
|
|
32
http.go
32
http.go
|
@ -315,14 +315,19 @@ func (s *Server) Port() (port int) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// FullHost returns the scheme+host
|
// Scheme returns http:// or https:// if SSL is enabled
|
||||||
func (s *Server) FullHost() string {
|
func (s *Server) Scheme() string {
|
||||||
scheme := "http://"
|
scheme := "http://"
|
||||||
// we need to be able to take that before(for testing &debugging) and after server's listen
|
// we need to be able to take that before(for testing &debugging) and after server's listen
|
||||||
if s.IsSecure() || (s.Config.CertFile != "" && s.Config.KeyFile != "") {
|
if s.IsSecure() || (s.Config.CertFile != "" && s.Config.KeyFile != "") {
|
||||||
scheme = "https://"
|
scheme = "https://"
|
||||||
}
|
}
|
||||||
return scheme + s.Host()
|
return scheme
|
||||||
|
}
|
||||||
|
|
||||||
|
// FullHost returns the scheme+host
|
||||||
|
func (s *Server) FullHost() string {
|
||||||
|
return s.Scheme() + s.Host()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hostname returns the hostname part of the host (host expect port)
|
// Hostname returns the hostname part of the host (host expect port)
|
||||||
|
@ -850,7 +855,7 @@ func (e *muxEntry) add(path string, middleware Middleware) error {
|
||||||
|
|
||||||
if len(path) >= len(e.part) && e.part == path[:len(e.part)] {
|
if len(path) >= len(e.part) && e.part == path[:len(e.part)] {
|
||||||
|
|
||||||
if len(e.part) >= len(path) || path[len(e.part)] == '/' {
|
if len(e.part) >= len(path) || path[len(e.part)] == slashByte {
|
||||||
continue loop
|
continue loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -859,7 +864,7 @@ func (e *muxEntry) add(path string, middleware Middleware) error {
|
||||||
|
|
||||||
c := path[0]
|
c := path[0]
|
||||||
|
|
||||||
if e.entryCase == hasParams && c == '/' && len(e.nodes) == 1 {
|
if e.entryCase == hasParams && c == slashByte && len(e.nodes) == 1 {
|
||||||
e = e.nodes[0]
|
e = e.nodes[0]
|
||||||
e.precedence++
|
e.precedence++
|
||||||
continue loop
|
continue loop
|
||||||
|
@ -1148,8 +1153,12 @@ type (
|
||||||
Method() string
|
Method() string
|
||||||
// Path returns the path
|
// Path returns the path
|
||||||
Path() string
|
Path() string
|
||||||
|
// SetPath changes/sets the path for this route
|
||||||
|
SetPath(string)
|
||||||
// Middleware returns the slice of Handler([]Handler) registed to this route
|
// Middleware returns the slice of Handler([]Handler) registed to this route
|
||||||
Middleware() Middleware
|
Middleware() Middleware
|
||||||
|
// SetMiddleware changes/sets the middleware(handler(s)) for this route
|
||||||
|
SetMiddleware(Middleware)
|
||||||
}
|
}
|
||||||
|
|
||||||
route struct {
|
route struct {
|
||||||
|
@ -1239,10 +1248,18 @@ func (r route) Path() string {
|
||||||
return r.path
|
return r.path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *route) SetPath(s string) {
|
||||||
|
r.path = s
|
||||||
|
}
|
||||||
|
|
||||||
func (r route) Middleware() Middleware {
|
func (r route) Middleware() Middleware {
|
||||||
return r.middleware
|
return r.middleware
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *route) SetMiddleware(m Middleware) {
|
||||||
|
r.middleware = m
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// subdomainIndicator where './' exists in a registed path then it contains subdomain
|
// subdomainIndicator where './' exists in a registed path then it contains subdomain
|
||||||
subdomainIndicator = "./"
|
subdomainIndicator = "./"
|
||||||
|
@ -1265,6 +1282,8 @@ type (
|
||||||
tree *muxTree
|
tree *muxTree
|
||||||
lookups []*route
|
lookups []*route
|
||||||
|
|
||||||
|
onLookup func(Route)
|
||||||
|
|
||||||
api *muxAPI
|
api *muxAPI
|
||||||
errorHandlers map[int]Handler
|
errorHandlers map[int]Handler
|
||||||
logger *logger.Logger
|
logger *logger.Logger
|
||||||
|
@ -1360,6 +1379,9 @@ func (mux *serveMux) register(method []byte, subdomain string, path string, midd
|
||||||
|
|
||||||
// add to the lookups, it's just a collection of routes information
|
// add to the lookups, it's just a collection of routes information
|
||||||
lookup := newRoute(method, subdomain, path, middleware)
|
lookup := newRoute(method, subdomain, path, middleware)
|
||||||
|
if mux.onLookup != nil {
|
||||||
|
mux.onLookup(lookup)
|
||||||
|
}
|
||||||
mux.lookups = append(mux.lookups, lookup)
|
mux.lookups = append(mux.lookups, lookup)
|
||||||
|
|
||||||
return lookup
|
return lookup
|
||||||
|
|
18
http_test.go
18
http_test.go
|
@ -103,6 +103,24 @@ func TestServerHostname(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestServerFullHost(t *testing.T) {
|
||||||
|
var server1 Server
|
||||||
|
var server2 Server
|
||||||
|
server1.Config.ListeningAddr = "127.0.0.1:8080"
|
||||||
|
server1.Config.CertFile = "notempty"
|
||||||
|
server1.Config.KeyFile = "notempty"
|
||||||
|
server2.Config.ListeningAddr = "127.0.0.1:8080"
|
||||||
|
server1ExpectingFullhost := "https://" + server1.Config.ListeningAddr
|
||||||
|
server2ExpectingFullhost := "http://" + server2.Config.ListeningAddr
|
||||||
|
if server1.FullHost() != server1ExpectingFullhost {
|
||||||
|
t.Fatalf("Expecting server 1's fullhost to be %s but got %s", server1ExpectingFullhost, server1.FullHost())
|
||||||
|
}
|
||||||
|
if server2.FullHost() != server2ExpectingFullhost {
|
||||||
|
t.Fatalf("Expecting server 2's fullhost to be %s but got %s", server2ExpectingFullhost, server2.FullHost())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func TestServerPort(t *testing.T) {
|
func TestServerPort(t *testing.T) {
|
||||||
var server1, server2 Server
|
var server1, server2 Server
|
||||||
expectedPort1 := 8080
|
expectedPort1 := 8080
|
||||||
|
|
25
iris.go
25
iris.go
|
@ -81,7 +81,7 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Version of the iris
|
// Version of the iris
|
||||||
Version = "3.0.0-pre.release"
|
Version = "3.0.0"
|
||||||
|
|
||||||
// HTMLEngine conversion for config.HTMLEngine
|
// HTMLEngine conversion for config.HTMLEngine
|
||||||
HTMLEngine = config.HTMLEngine
|
HTMLEngine = config.HTMLEngine
|
||||||
|
@ -165,8 +165,12 @@ type (
|
||||||
Go() error
|
Go() error
|
||||||
Close() error
|
Close() error
|
||||||
// global middleware prepending, registers to all subdomains, to all parties, you can call it at the last also
|
// global middleware prepending, registers to all subdomains, to all parties, you can call it at the last also
|
||||||
|
// deprecated Start
|
||||||
MustUse(...Handler)
|
MustUse(...Handler)
|
||||||
MustUseFunc(...HandlerFunc)
|
MustUseFunc(...HandlerFunc)
|
||||||
|
// deprecated End
|
||||||
|
UseGlobal(...Handler)
|
||||||
|
UseGlobalFunc(...HandlerFunc)
|
||||||
OnError(int, HandlerFunc)
|
OnError(int, HandlerFunc)
|
||||||
EmitError(int, *Context)
|
EmitError(int, *Context)
|
||||||
Lookup(string) Route
|
Lookup(string) Route
|
||||||
|
@ -220,6 +224,7 @@ func New(cfg ...config.Iris) *Framework {
|
||||||
s.Websocket = websocket.NewServer(s.Config.Websocket)
|
s.Websocket = websocket.NewServer(s.Config.Websocket)
|
||||||
// set the servemux, which will provide us the public API also, with its context pool
|
// set the servemux, which will provide us the public API also, with its context pool
|
||||||
mux := newServeMux(sync.Pool{New: func() interface{} { return &Context{framework: s} }}, s.Logger)
|
mux := newServeMux(sync.Pool{New: func() interface{} { return &Context{framework: s} }}, s.Logger)
|
||||||
|
mux.onLookup = s.Plugins.DoPreLookup
|
||||||
// set the public router API (and party)
|
// set the public router API (and party)
|
||||||
s.muxAPI = &muxAPI{mux: mux, relativePath: "/"}
|
s.muxAPI = &muxAPI{mux: mux, relativePath: "/"}
|
||||||
|
|
||||||
|
@ -247,7 +252,6 @@ func (s *Framework) initialize() {
|
||||||
// prepare the mux & the server
|
// prepare the mux & the server
|
||||||
s.mux.setCorrectPath(!s.Config.DisablePathCorrection)
|
s.mux.setCorrectPath(!s.Config.DisablePathCorrection)
|
||||||
s.mux.setEscapePath(!s.Config.DisablePathEscape)
|
s.mux.setEscapePath(!s.Config.DisablePathEscape)
|
||||||
|
|
||||||
// set the debug profiling handlers if ProfilePath is setted
|
// set the debug profiling handlers if ProfilePath is setted
|
||||||
if debugPath := s.Config.ProfilePath; debugPath != "" {
|
if debugPath := s.Config.ProfilePath; debugPath != "" {
|
||||||
s.Handle(MethodGet, debugPath+"/*action", profileMiddleware(debugPath)...)
|
s.Handle(MethodGet, debugPath+"/*action", profileMiddleware(debugPath)...)
|
||||||
|
@ -479,37 +483,37 @@ func (s *Framework) Close() error {
|
||||||
return s.Servers.CloseAll()
|
return s.Servers.CloseAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MustUse registers Handler middleware to the beginning, prepends them instead of append
|
// UseGlobal registers Handler middleware to the beginning, prepends them instead of append
|
||||||
//
|
//
|
||||||
// Use it when you want to add a global middleware to all parties, to all routes in all subdomains
|
// 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)
|
// It can be called after other, (but before .Listen of course)
|
||||||
func MustUse(handlers ...Handler) {
|
func UseGlobal(handlers ...Handler) {
|
||||||
Default.MustUse(handlers...)
|
Default.MustUse(handlers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MustUseFunc registers HandlerFunc middleware to the beginning, prepends them instead of append
|
// UseGlobalFunc registers HandlerFunc middleware to the beginning, prepends them instead of append
|
||||||
//
|
//
|
||||||
// Use it when you want to add a global middleware to all parties, to all routes in all subdomains
|
// 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)
|
// It can be called after other, (but before .Listen of course)
|
||||||
func MustUseFunc(handlersFn ...HandlerFunc) {
|
func UseGlobalFunc(handlersFn ...HandlerFunc) {
|
||||||
Default.MustUseFunc(handlersFn...)
|
Default.MustUseFunc(handlersFn...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MustUse registers Handler middleware to the beginning, prepends them instead of append
|
// UseGlobal registers Handler middleware to the beginning, prepends them instead of append
|
||||||
//
|
//
|
||||||
// Use it when you want to add a global middleware to all parties, to all routes in all subdomains
|
// 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)
|
// It can be called after other, (but before .Listen of course)
|
||||||
func (s *Framework) MustUse(handlers ...Handler) {
|
func (s *Framework) UseGlobal(handlers ...Handler) {
|
||||||
for _, r := range s.mux.lookups {
|
for _, r := range s.mux.lookups {
|
||||||
r.middleware = append(handlers, r.middleware...)
|
r.middleware = append(handlers, r.middleware...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MustUseFunc registers HandlerFunc middleware to the beginning, prepends them instead of append
|
// UseGlobalFunc registers HandlerFunc middleware to the beginning, prepends them instead of append
|
||||||
//
|
//
|
||||||
// Use it when you want to add a global middleware to all parties, to all routes in all subdomains
|
// 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)
|
// It can be called after other, (but before .Listen of course)
|
||||||
func (s *Framework) MustUseFunc(handlersFn ...HandlerFunc) {
|
func (s *Framework) UseGlobalFunc(handlersFn ...HandlerFunc) {
|
||||||
s.MustUse(convertToHandlers(handlersFn)...)
|
s.MustUse(convertToHandlers(handlersFn)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -914,6 +918,7 @@ func (api *muxAPI) Handle(method string, registedPath string, handlers ...Handle
|
||||||
}
|
}
|
||||||
|
|
||||||
path = strings.Replace(path, "//", "/", -1) // fix the path if double //
|
path = strings.Replace(path, "//", "/", -1) // fix the path if double //
|
||||||
|
|
||||||
return api.mux.register([]byte(method), subdomain, path, middleware).setName
|
return api.mux.register([]byte(method), subdomain, path, middleware).setName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
31
plugin.go
31
plugin.go
|
@ -53,6 +53,13 @@ type (
|
||||||
// PluginContainer parameter used to add other plugins if that's necessary by the plugin
|
// PluginContainer parameter used to add other plugins if that's necessary by the plugin
|
||||||
Activate(PluginContainer) error
|
Activate(PluginContainer) error
|
||||||
}
|
}
|
||||||
|
// pluginPreLookup implements the PreRoute(Route) method
|
||||||
|
pluginPreLookup interface {
|
||||||
|
// PreLookup called before register a route
|
||||||
|
PreLookup(Route)
|
||||||
|
}
|
||||||
|
// PreLookupFunc implements the simple function listener for the PreLookup(Route)
|
||||||
|
PreLookupFunc func(Route)
|
||||||
// pluginPreListen implements the PreListen(*Framework) method
|
// pluginPreListen implements the PreListen(*Framework) method
|
||||||
pluginPreListen interface {
|
pluginPreListen interface {
|
||||||
// PreListen it's being called only one time, BEFORE the Server is started (if .Listen called)
|
// PreListen it's being called only one time, BEFORE the Server is started (if .Listen called)
|
||||||
|
@ -105,6 +112,8 @@ type (
|
||||||
GetDescription(Plugin) string
|
GetDescription(Plugin) string
|
||||||
GetByName(string) Plugin
|
GetByName(string) Plugin
|
||||||
Printf(string, ...interface{})
|
Printf(string, ...interface{})
|
||||||
|
PreLookup(PreLookupFunc)
|
||||||
|
DoPreLookup(Route)
|
||||||
PreListen(PreListenFunc)
|
PreListen(PreListenFunc)
|
||||||
DoPreListen(*Framework)
|
DoPreListen(*Framework)
|
||||||
DoPreListenParallel(*Framework)
|
DoPreListenParallel(*Framework)
|
||||||
|
@ -148,6 +157,11 @@ type (
|
||||||
|
|
||||||
// convert the functions to plugin
|
// convert the functions to plugin
|
||||||
|
|
||||||
|
// PreLookup called before register a route
|
||||||
|
func (fn PreLookupFunc) PreLookup(r Route) {
|
||||||
|
fn(r)
|
||||||
|
}
|
||||||
|
|
||||||
// PreListen it's being called only one time, BEFORE the Server is started (if .Listen called)
|
// PreListen it's being called only one time, BEFORE the Server is started (if .Listen called)
|
||||||
// is used to do work at the time all other things are ready to go
|
// is used to do work at the time all other things are ready to go
|
||||||
// parameter is the station
|
// parameter is the station
|
||||||
|
@ -339,12 +353,27 @@ func (p *pluginContainer) Printf(format string, a ...interface{}) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PreLookup adds a PreLookup plugin-function to the plugin flow container
|
||||||
|
func (p *pluginContainer) PreLookup(fn PreLookupFunc) {
|
||||||
|
p.Add(fn)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DoPreLookup raise all plugins which has the PreLookup method
|
||||||
|
func (p *pluginContainer) DoPreLookup(r Route) {
|
||||||
|
for i := range p.activatedPlugins {
|
||||||
|
// check if this method exists on our plugin obj, these are optionaly and call it
|
||||||
|
if pluginObj, ok := p.activatedPlugins[i].(pluginPreLookup); ok {
|
||||||
|
pluginObj.PreLookup(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// PreListen adds a PreListen plugin-function to the plugin flow container
|
// PreListen adds a PreListen plugin-function to the plugin flow container
|
||||||
func (p *pluginContainer) PreListen(fn PreListenFunc) {
|
func (p *pluginContainer) PreListen(fn PreListenFunc) {
|
||||||
p.Add(fn)
|
p.Add(fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DoPreListen raise all plugins which has the DoPreListen method
|
// DoPreListen raise all plugins which has the PreListen method
|
||||||
func (p *pluginContainer) DoPreListen(station *Framework) {
|
func (p *pluginContainer) DoPreListen(station *Framework) {
|
||||||
for i := range p.activatedPlugins {
|
for i := range p.activatedPlugins {
|
||||||
// check if this method exists on our plugin obj, these are optionaly and call it
|
// check if this method exists on our plugin obj, these are optionaly and call it
|
||||||
|
|
Loading…
Reference in New Issue
Block a user