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 (
|
2019-10-24 17:57:05 +02:00
|
|
|
"errors"
|
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
|
|
|
"net/http"
|
2020-08-12 06:20:07 +02:00
|
|
|
"sort"
|
|
|
|
"strings"
|
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
|
|
|
"sync"
|
|
|
|
|
2019-10-25 00:27:02 +02:00
|
|
|
"github.com/kataras/iris/v12/context"
|
2019-12-16 01:00:42 +01:00
|
|
|
|
|
|
|
"github.com/schollz/closestmatch"
|
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
|
|
|
)
|
|
|
|
|
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,
|
2020-08-09 21:28:44 +02: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
|
|
|
requestHandler RequestHandler // build-accessible, can be changed to define a custom router or proxy, used on RefreshRouter too.
|
|
|
|
mainHandler http.HandlerFunc // init-accessible
|
2020-06-10 22:37:50 +02:00
|
|
|
wrapperFunc WrapperFunc
|
2020-08-16 17:04:52 +02:00
|
|
|
// wrappers to be built on BuildRouter state,
|
|
|
|
// first is executed first at this case.
|
|
|
|
// Case:
|
|
|
|
// - SubdomainRedirect on user call, registers a wrapper, on design state
|
|
|
|
// - i18n,if loaded and Subdomain or PathRedirect is true, registers a wrapper too, on build state
|
|
|
|
// the SubdomainRedirect should be the first(subdomainWrap(i18nWrap)) wrapper
|
|
|
|
// to be executed instead of last(i18nWrap(subdomainWrap)).
|
|
|
|
wrapperFuncs []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
|
|
|
|
|
|
|
cPool *context.Pool // used on RefreshRouter
|
|
|
|
routesProvider RoutesProvider
|
2019-12-16 01:00:42 +01:00
|
|
|
|
|
|
|
// key = subdomain
|
|
|
|
// value = closest of static routes, filled on `BuildRouter/RefreshRouter`.
|
|
|
|
closestPaths map[string]*closestmatch.ClosestMatch
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// NewRouter returns a new empty Router.
|
2019-12-16 01:00:42 +01:00
|
|
|
func NewRouter() *Router {
|
|
|
|
return &Router{}
|
|
|
|
}
|
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
|
|
|
|
|
|
|
// 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
|
|
|
}
|
|
|
|
|
2019-12-13 22:06:18 +01:00
|
|
|
// ErrNotRouteAdder throws on `AddRouteUnsafe` when a registered `RequestHandler`
|
|
|
|
// does not implements the optional `AddRoute(*Route) error` method.
|
|
|
|
var ErrNotRouteAdder = errors.New("request handler does not implement AddRoute method")
|
|
|
|
|
|
|
|
// AddRouteUnsafe adds a route directly to the router's request handler.
|
|
|
|
// Works before or after Build state.
|
|
|
|
// Mainly used for internal cases like `iris.WithSitemap`.
|
|
|
|
// Do NOT use it on serve-time.
|
2020-05-08 02:55:54 +02:00
|
|
|
func (router *Router) AddRouteUnsafe(routes ...*Route) error {
|
2019-12-13 22:06:18 +01:00
|
|
|
if h := router.requestHandler; h != nil {
|
|
|
|
if v, ok := h.(interface {
|
|
|
|
AddRoute(*Route) error
|
|
|
|
}); ok {
|
2020-05-08 02:55:54 +02:00
|
|
|
for _, r := range routes {
|
|
|
|
return v.AddRoute(r)
|
|
|
|
}
|
2019-12-13 22:06:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ErrNotRouteAdder
|
|
|
|
}
|
|
|
|
|
2019-12-16 01:00:42 +01:00
|
|
|
// FindClosestPaths returns a list of "n" paths close to "path" under the given "subdomain".
|
|
|
|
//
|
|
|
|
// Order may change.
|
|
|
|
func (router *Router) FindClosestPaths(subdomain, searchPath string, n int) []string {
|
|
|
|
if router.closestPaths == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
cm, ok := router.closestPaths[subdomain]
|
|
|
|
if !ok {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
list := cm.ClosestN(searchPath, n)
|
|
|
|
if len(list) == 1 && list[0] == "" {
|
|
|
|
// yes, it may return empty string as its first slice element when not found.
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return list
|
|
|
|
}
|
|
|
|
|
2020-08-12 06:20:07 +02:00
|
|
|
func (router *Router) buildMainHandlerWithFilters(routerFilters map[Party]*Filter, cPool *context.Pool, requestHandler RequestHandler) {
|
|
|
|
sortedFilters := make([]*Filter, 0, len(routerFilters))
|
|
|
|
// key was just there to enforce uniqueness on API level.
|
|
|
|
for _, f := range routerFilters {
|
|
|
|
sortedFilters = append(sortedFilters, f)
|
|
|
|
// append it as one handlers so execution rules are being respected in that step too.
|
|
|
|
f.Handlers = append(f.Handlers, func(ctx *context.Context) {
|
|
|
|
// set the handler index back to 0 so the route's handlers can be executed as expected.
|
|
|
|
ctx.HandlerIndex(0)
|
|
|
|
// execute the main request handler, this will fire the found route's handlers
|
|
|
|
// or if error the error code's associated handler.
|
|
|
|
router.requestHandler.HandleRequest(ctx)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
sort.SliceStable(sortedFilters, func(i, j int) bool {
|
|
|
|
left, right := sortedFilters[i], sortedFilters[j]
|
|
|
|
var (
|
|
|
|
leftSubLen = len(left.Subdomain)
|
|
|
|
rightSubLen = len(right.Subdomain)
|
|
|
|
|
|
|
|
leftSlashLen = strings.Count(left.Path, "/")
|
|
|
|
rightSlashLen = strings.Count(right.Path, "/")
|
|
|
|
)
|
|
|
|
|
|
|
|
if leftSubLen == rightSubLen {
|
|
|
|
if leftSlashLen > rightSlashLen {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if leftSubLen > rightSubLen {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
if leftSlashLen > rightSlashLen {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
if leftSlashLen == rightSlashLen {
|
2021-01-09 04:41:20 +01:00
|
|
|
return len(left.Path) > len(right.Path)
|
2020-08-12 06:20:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return len(left.Path) > len(right.Path)
|
|
|
|
})
|
|
|
|
|
|
|
|
router.mainHandler = func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := cPool.Acquire(w, r)
|
|
|
|
|
|
|
|
filterExecuted := false
|
2020-08-26 05:57:36 +02:00
|
|
|
for _, f := range sortedFilters { // from subdomain, largest path to shortest.
|
2020-08-12 06:20:07 +02:00
|
|
|
// fmt.Printf("Sorted filter execution: [%s] [%s]\n", f.Subdomain, f.Path)
|
|
|
|
if f.Matcher.Match(ctx) {
|
|
|
|
// fmt.Printf("Matched [%s] and execute [%d] handlers [%s]\n\n", ctx.Path(), len(f.Handlers), context.HandlersNames(f.Handlers))
|
|
|
|
filterExecuted = true
|
|
|
|
// execute the final handlers chain.
|
|
|
|
ctx.Do(f.Handlers)
|
2020-08-26 05:57:36 +02:00
|
|
|
break // and break on first found.
|
2020-08-12 06:20:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if !filterExecuted {
|
|
|
|
// If not at least one match filter found and executed,
|
|
|
|
// then just run the router.
|
|
|
|
router.requestHandler.HandleRequest(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
cPool.Release(ctx)
|
|
|
|
}
|
2020-08-09 21:28:44 +02: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
|
|
|
// 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
|
|
|
|
2020-08-12 06:20:07 +02:00
|
|
|
// the important stuff.
|
|
|
|
if routerFilters := routesProvider.GetRouterFilters(); len(routerFilters) > 0 {
|
|
|
|
router.buildMainHandlerWithFilters(routerFilters, cPool, requestHandler)
|
2020-08-09 21:28:44 +02:00
|
|
|
} else {
|
|
|
|
router.mainHandler = func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := cPool.Acquire(w, r)
|
|
|
|
router.requestHandler.HandleRequest(ctx)
|
|
|
|
cPool.Release(ctx)
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2020-08-16 17:04:52 +02:00
|
|
|
for i := len(router.wrapperFuncs) - 1; i >= 0; i-- {
|
|
|
|
w := router.wrapperFuncs[i]
|
|
|
|
if w == nil {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
router.WrapRouter(w)
|
|
|
|
}
|
|
|
|
|
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 { // if wrapper used then attach that as the router service
|
2020-06-10 22:37:50 +02:00
|
|
|
router.mainHandler = newWrapper(router.wrapperFunc, router.mainHandler).ServeHTTP
|
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
|
|
|
}
|
|
|
|
|
2019-12-16 01:00:42 +01:00
|
|
|
// build closest.
|
|
|
|
subdomainPaths := make(map[string][]string)
|
|
|
|
for _, r := range router.routesProvider.GetRoutes() {
|
|
|
|
if !r.IsStatic() {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
subdomainPaths[r.Subdomain] = append(subdomainPaths[r.Subdomain], r.Path)
|
|
|
|
}
|
|
|
|
|
|
|
|
router.closestPaths = make(map[string]*closestmatch.ClosestMatch)
|
|
|
|
for subdomain, paths := range subdomainPaths {
|
|
|
|
router.closestPaths[subdomain] = closestmatch.New(paths, []int{3, 4, 6})
|
|
|
|
}
|
|
|
|
|
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
|
|
|
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
|
|
|
|
}
|
|
|
|
|
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) {
|
2020-08-16 17:04:52 +02:00
|
|
|
// logger := context.DefaultLogger("router wrapper")
|
|
|
|
// file, line := context.HandlerFileLineRel(wrapperFunc)
|
|
|
|
// if router.wrapperFunc != nil {
|
|
|
|
// wrappedFile, wrappedLine := context.HandlerFileLineRel(router.wrapperFunc)
|
|
|
|
// logger.Infof("%s:%d wraps %s:%d", file, line, wrappedFile, wrappedLine)
|
|
|
|
// } else {
|
|
|
|
// logger.Infof("%s:%d wraps the main router", file, line)
|
|
|
|
// }
|
2020-06-10 22:37:50 +02:00
|
|
|
router.wrapperFunc = makeWrapperFunc(router.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
|
|
|
}
|
|
|
|
|
2020-08-16 17:04:52 +02:00
|
|
|
// AddRouterWrapper adds a router wrapper.
|
|
|
|
// Unlike `WrapRouter` the first registered will be executed first
|
|
|
|
// so a wrapper wraps its next not the previous one.
|
|
|
|
// it defers the wrapping until the `BuildRouter`.
|
|
|
|
// Redirection wrappers should be added using this method
|
|
|
|
// e.g. SubdomainRedirect.
|
|
|
|
func (router *Router) AddRouterWrapper(wrapperFunc WrapperFunc) {
|
|
|
|
router.wrapperFuncs = append(router.wrapperFuncs, wrapperFunc)
|
|
|
|
}
|
|
|
|
|
|
|
|
// PrependRouterWrapper like `AddRouterWrapper` but this wrapperFunc
|
|
|
|
// will always be executed before the previous `AddRouterWrapper`.
|
|
|
|
// Path form (no modification) wrappers should be added using this method
|
|
|
|
// e.g. ForceLowercaseRouting.
|
|
|
|
func (router *Router) PrependRouterWrapper(wrapperFunc WrapperFunc) {
|
|
|
|
router.wrapperFuncs = append([]WrapperFunc{wrapperFunc}, router.wrapperFuncs...)
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// ServeHTTPC serves the raw context, useful if we have already a context, it by-pass the wrapper.
|
2020-07-10 22:21:09 +02:00
|
|
|
func (router *Router) ServeHTTPC(ctx *context.Context) {
|
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)
|
|
|
|
}
|
|
|
|
|
|
|
|
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.
|
2020-07-10 22:21:09 +02:00
|
|
|
func (router *Router) RouteExists(ctx *context.Context, method, path string) bool {
|
2018-03-10 13:22:56 +01:00
|
|
|
return router.requestHandler.RouteExists(ctx, method, path)
|
2018-02-21 10:27:01 +01:00
|
|
|
}
|