Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
package router
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"sync"
|
|
|
|
|
|
|
|
"github.com/kataras/iris/context"
|
|
|
|
"github.com/kataras/iris/core/errors"
|
|
|
|
)
|
|
|
|
|
2017-06-10 02:56:42 +02:00
|
|
|
// Router is the "director".
|
|
|
|
// Caller should provide a request handler (router implementation or root handler).
|
|
|
|
// Router is responsible to build the received request handler and run it
|
|
|
|
// to serve requests, based on the received context.Pool.
|
|
|
|
//
|
|
|
|
// User can refresh the router with `RefreshRouter` whenever a route's field is changed by him.
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
type Router struct {
|
|
|
|
mu sync.Mutex // for Downgrade, WrapRouter & BuildRouter,
|
|
|
|
// not indeed but we don't to risk its usage by third-parties.
|
|
|
|
requestHandler RequestHandler // build-accessible, can be changed to define a custom router or proxy, used on RefreshRouter too.
|
|
|
|
mainHandler http.HandlerFunc // init-accessible
|
|
|
|
wrapperFunc func(http.ResponseWriter, *http.Request, http.HandlerFunc)
|
|
|
|
|
|
|
|
cPool *context.Pool // used on RefreshRouter
|
|
|
|
routesProvider RoutesProvider
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewRouter returns a new empty Router.
|
|
|
|
func NewRouter() *Router { return &Router{} }
|
|
|
|
|
|
|
|
// RefreshRouter re-builds the router. Should be called when a route's state
|
|
|
|
// changed (i.e Method changed at serve-time).
|
|
|
|
func (router *Router) RefreshRouter() error {
|
2018-10-21 18:20:05 +02:00
|
|
|
return router.BuildRouter(router.cPool, router.requestHandler, router.routesProvider, true)
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// BuildRouter builds the router based on
|
|
|
|
// the context factory (explicit pool in this case),
|
|
|
|
// the request handler which manages how the main handler will multiplexes the routes
|
|
|
|
// provided by the third parameter, routerProvider (it's the api builder in this case) and
|
|
|
|
// its wrapper.
|
|
|
|
//
|
|
|
|
// Use of RefreshRouter to re-build the router if needed.
|
2018-10-21 18:20:05 +02:00
|
|
|
func (router *Router) BuildRouter(cPool *context.Pool, requestHandler RequestHandler, routesProvider RoutesProvider, force bool) error {
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
|
|
|
|
if requestHandler == nil {
|
|
|
|
return errors.New("router: request handler is nil")
|
|
|
|
}
|
|
|
|
|
|
|
|
if cPool == nil {
|
|
|
|
return errors.New("router: context pool is nil")
|
|
|
|
}
|
|
|
|
|
|
|
|
// build the handler using the routesProvider
|
|
|
|
if err := requestHandler.Build(routesProvider); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
router.mu.Lock()
|
|
|
|
defer router.mu.Unlock()
|
|
|
|
|
|
|
|
// store these for RefreshRouter's needs.
|
2018-10-21 18:20:05 +02:00
|
|
|
if force {
|
|
|
|
router.cPool = cPool
|
|
|
|
router.requestHandler = requestHandler
|
|
|
|
router.routesProvider = routesProvider
|
|
|
|
} else {
|
|
|
|
if router.cPool == nil {
|
|
|
|
router.cPool = cPool
|
|
|
|
}
|
|
|
|
|
|
|
|
if router.requestHandler == nil {
|
|
|
|
router.requestHandler = requestHandler
|
|
|
|
}
|
|
|
|
|
|
|
|
if router.routesProvider == nil && routesProvider != nil {
|
|
|
|
router.routesProvider = routesProvider
|
|
|
|
}
|
|
|
|
}
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
|
|
|
|
// the important
|
|
|
|
router.mainHandler = func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := cPool.Acquire(w, r)
|
2019-08-06 14:39:42 +02:00
|
|
|
// Note: we can't get all r.Context().Value key-value pairs
|
|
|
|
// and save them to ctx.values.
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
router.requestHandler.HandleRequest(ctx)
|
|
|
|
cPool.Release(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
if router.wrapperFunc != nil { // if wrapper used then attach that as the router service
|
|
|
|
router.mainHandler = NewWrapper(router.wrapperFunc, router.mainHandler).ServeHTTP
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Downgrade "downgrades", alters the router supervisor service(Router.mainHandler)
|
2019-06-14 10:26:56 +02:00
|
|
|
// algorithm to a custom one,
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// be aware to change the global variables of 'ParamStart' and 'ParamWildcardStart'.
|
|
|
|
// can be used to implement a custom proxy or
|
|
|
|
// a custom router which should work with raw ResponseWriter, *Request
|
2017-12-18 06:22:55 +01:00
|
|
|
// instead of the Context(which again, can be retrieved by the Framework's context pool).
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
//
|
|
|
|
// Note: Downgrade will by-pass the Wrapper, the caller is responsible for everything.
|
|
|
|
// Downgrade is thread-safe.
|
|
|
|
func (router *Router) Downgrade(newMainHandler http.HandlerFunc) {
|
|
|
|
router.mu.Lock()
|
|
|
|
router.mainHandler = newMainHandler
|
|
|
|
router.mu.Unlock()
|
|
|
|
}
|
|
|
|
|
2017-06-10 02:31:50 +02:00
|
|
|
// Downgraded returns true if this router is downgraded.
|
|
|
|
func (router *Router) Downgraded() bool {
|
|
|
|
return router.mainHandler != nil && router.requestHandler == nil
|
|
|
|
}
|
|
|
|
|
2017-06-15 19:02:08 +02:00
|
|
|
// WrapperFunc is used as an expected input parameter signature
|
|
|
|
// for the WrapRouter. It's a "low-level" signature which is compatible
|
|
|
|
// with the net/http.
|
|
|
|
// It's being used to run or no run the router based on a custom logic.
|
|
|
|
type WrapperFunc func(w http.ResponseWriter, r *http.Request, firstNextIsTheRouter http.HandlerFunc)
|
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// WrapRouter adds a wrapper on the top of the main router.
|
|
|
|
// Usually it's useful for third-party middleware
|
|
|
|
// when need to wrap the entire application with a middleware like CORS.
|
|
|
|
//
|
|
|
|
// Developers can add more than one wrappers,
|
|
|
|
// those wrappers' execution comes from last to first.
|
|
|
|
// That means that the second wrapper will wrap the first, and so on.
|
|
|
|
//
|
|
|
|
// Before build.
|
2017-06-15 19:02:08 +02:00
|
|
|
func (router *Router) WrapRouter(wrapperFunc WrapperFunc) {
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
if wrapperFunc == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-01-20 04:17:31 +01:00
|
|
|
router.mu.Lock()
|
|
|
|
defer router.mu.Unlock()
|
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
if router.wrapperFunc != nil {
|
|
|
|
// wrap into one function, from bottom to top, end to begin.
|
|
|
|
nextWrapper := wrapperFunc
|
|
|
|
prevWrapper := router.wrapperFunc
|
|
|
|
wrapperFunc = func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
|
|
|
|
if next != nil {
|
|
|
|
nexthttpFunc := http.HandlerFunc(func(_w http.ResponseWriter, _r *http.Request) {
|
|
|
|
prevWrapper(_w, _r, next)
|
|
|
|
})
|
|
|
|
nextWrapper(w, r, nexthttpFunc)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
router.wrapperFunc = wrapperFunc
|
|
|
|
}
|
|
|
|
|
|
|
|
// ServeHTTPC serves the raw context, useful if we have already a context, it by-pass the wrapper.
|
|
|
|
func (router *Router) ServeHTTPC(ctx context.Context) {
|
|
|
|
router.requestHandler.HandleRequest(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (router *Router) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
|
|
router.mainHandler(w, r)
|
|
|
|
}
|
|
|
|
|
2018-03-10 13:22:56 +01:00
|
|
|
// RouteExists reports whether a particular route exists
|
|
|
|
// It will search from the current subdomain of context's host, if not inside the root domain.
|
|
|
|
func (router *Router) RouteExists(ctx context.Context, method, path string) bool {
|
|
|
|
return router.requestHandler.RouteExists(ctx, method, path)
|
2018-02-21 10:27:01 +01:00
|
|
|
}
|
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
type wrapper struct {
|
|
|
|
router http.HandlerFunc // http.HandlerFunc to catch the CURRENT state of its .ServeHTTP on case of future change.
|
|
|
|
wrapperFunc func(http.ResponseWriter, *http.Request, http.HandlerFunc)
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewWrapper returns a new http.Handler wrapped by the 'wrapperFunc'
|
|
|
|
// the "next" is the final "wrapped" input parameter.
|
|
|
|
//
|
|
|
|
// Application is responsible to make it to work on more than one wrappers
|
|
|
|
// via composition or func clojure.
|
|
|
|
func NewWrapper(wrapperFunc func(w http.ResponseWriter, r *http.Request, routerNext http.HandlerFunc), wrapped http.HandlerFunc) http.Handler {
|
|
|
|
return &wrapper{
|
|
|
|
wrapperFunc: wrapperFunc,
|
|
|
|
router: wrapped,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (wr *wrapper) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
|
|
wr.wrapperFunc(w, r, wr.router)
|
|
|
|
}
|