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 (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/kataras/iris/context"
|
|
|
|
"github.com/kataras/iris/core/router/macro"
|
|
|
|
)
|
|
|
|
|
2017-06-10 02:56:42 +02:00
|
|
|
// Route contains the information about a registered Route.
|
|
|
|
// If any of the following fields are changed then the
|
|
|
|
// caller should Refresh the 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
|
|
|
type Route struct {
|
|
|
|
Name string // "userRoute"
|
|
|
|
Method string // "GET"
|
|
|
|
Subdomain string // "admin."
|
|
|
|
tmpl *macro.Template // Tmpl().Src: "/api/user/{id:int}"
|
|
|
|
Path string // "/api/user/:id"
|
2017-07-23 11:10:51 +02:00
|
|
|
// temp storage, they're appended to the Handlers on build.
|
|
|
|
// Execution happens before Handlers, can be empty.
|
|
|
|
beginHandlers context.Handlers
|
|
|
|
// Handlers are the main route's handlers, executed by order.
|
|
|
|
// Cannot be empty.
|
2017-11-04 01:59:21 +01:00
|
|
|
Handlers context.Handlers
|
2017-12-04 04:06:03 +01:00
|
|
|
MainHandlerName string
|
2017-07-23 11:10:51 +02:00
|
|
|
// temp storage, they're appended to the Handlers on build.
|
|
|
|
// Execution happens after Begin and main Handler(s), can be empty.
|
|
|
|
doneHandlers context.Handlers
|
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
|
|
|
// FormattedPath all dynamic named parameters (if any) replaced with %v,
|
|
|
|
// used by Application to validate param values of a Route based on its name.
|
|
|
|
FormattedPath string
|
|
|
|
}
|
|
|
|
|
2017-06-10 02:56:42 +02:00
|
|
|
// NewRoute returns a new route based on its method,
|
|
|
|
// subdomain, the path (unparsed or original),
|
|
|
|
// handlers and the macro container which all routes should share.
|
|
|
|
// It parses the path based on the "macros",
|
|
|
|
// handlers are being changed to validate the macros at serve time, if needed.
|
2017-11-04 01:59:21 +01:00
|
|
|
func NewRoute(method, subdomain, unparsedPath, mainHandlerName string,
|
2017-06-12 03:47:16 +02:00
|
|
|
handlers context.Handlers, macros *macro.Map) (*Route, 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
|
|
|
|
|
|
|
tmpl, err := macro.Parse(unparsedPath, macros)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
path, handlers, err := compileRoutePathAndHandlers(handlers, tmpl)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
path = cleanPath(path) // maybe unnecessary here but who cares in this moment
|
2017-08-23 15:46:55 +02:00
|
|
|
defaultName := method + subdomain + tmpl.Src
|
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
|
|
|
formattedPath := formatPath(path)
|
|
|
|
|
|
|
|
route := &Route{
|
2017-11-04 01:59:21 +01:00
|
|
|
Name: defaultName,
|
|
|
|
Method: method,
|
|
|
|
Subdomain: subdomain,
|
|
|
|
tmpl: tmpl,
|
|
|
|
Path: path,
|
|
|
|
Handlers: handlers,
|
2017-12-04 04:06:03 +01:00
|
|
|
MainHandlerName: mainHandlerName,
|
2017-11-04 01:59:21 +01:00
|
|
|
FormattedPath: formattedPath,
|
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 route, nil
|
|
|
|
}
|
|
|
|
|
2017-07-23 11:10:51 +02:00
|
|
|
// use adds explicit begin handlers(middleware) to this route,
|
|
|
|
// It's being called internally, it's useless for outsiders
|
|
|
|
// because `Handlers` field is exported.
|
|
|
|
// The callers of this function are: `APIBuilder#UseGlobal` and `APIBuilder#Done`.
|
|
|
|
//
|
|
|
|
// BuildHandlers should be called to build the route's `Handlers`.
|
|
|
|
func (r *Route) use(handlers context.Handlers) {
|
|
|
|
if len(handlers) == 0 {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
r.beginHandlers = append(r.beginHandlers, handlers...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// use adds explicit done handlers to this route.
|
|
|
|
// It's being called internally, it's useless for outsiders
|
|
|
|
// because `Handlers` field is exported.
|
|
|
|
// The callers of this function are: `APIBuilder#UseGlobal` and `APIBuilder#Done`.
|
|
|
|
//
|
|
|
|
// BuildHandlers should be called to build the route's `Handlers`.
|
|
|
|
func (r *Route) done(handlers context.Handlers) {
|
|
|
|
if len(handlers) == 0 {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
r.doneHandlers = append(r.doneHandlers, handlers...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// BuildHandlers is executed automatically by the router handler
|
|
|
|
// at the `Application#Build` state. Do not call it manually, unless
|
|
|
|
// you were defined your own request mux handler.
|
|
|
|
func (r *Route) BuildHandlers() {
|
|
|
|
if len(r.beginHandlers) > 0 {
|
|
|
|
r.Handlers = append(r.beginHandlers, r.Handlers...)
|
|
|
|
r.beginHandlers = r.beginHandlers[0:0]
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(r.doneHandlers) > 0 {
|
|
|
|
r.Handlers = append(r.Handlers, r.doneHandlers...)
|
|
|
|
r.doneHandlers = r.doneHandlers[0:0]
|
|
|
|
} // note: no mutex needed, this should be called in-sync when server is not running of course.
|
|
|
|
}
|
|
|
|
|
2017-08-23 15:46:55 +02:00
|
|
|
// String returns the form of METHOD, SUBDOMAIN, TMPL PATH.
|
2017-07-10 17:32:42 +02:00
|
|
|
func (r Route) String() string {
|
|
|
|
return fmt.Sprintf("%s %s%s",
|
|
|
|
r.Method, r.Subdomain, r.Tmpl().Src)
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// Tmpl returns the path template, i
|
|
|
|
// it contains the parsed template
|
|
|
|
// for the route's path.
|
|
|
|
// May contain zero named parameters.
|
|
|
|
//
|
|
|
|
// Developer can get his registered path
|
|
|
|
// via Tmpl().Src, Route.Path is the path
|
|
|
|
// converted to match the underline router's specs.
|
|
|
|
func (r Route) Tmpl() macro.Template {
|
|
|
|
return *r.tmpl
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsOnline returns true if the route is marked as "online" (state).
|
|
|
|
func (r Route) IsOnline() bool {
|
|
|
|
return r.Method != MethodNone
|
|
|
|
}
|
|
|
|
|
2017-06-11 22:07:50 +02:00
|
|
|
// formats the parsed to the underline path syntax.
|
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
|
|
|
// path = "/api/users/:id"
|
|
|
|
// return "/api/users/%v"
|
|
|
|
//
|
|
|
|
// path = "/files/*file"
|
|
|
|
// return /files/%v
|
|
|
|
//
|
|
|
|
// path = "/:username/messages/:messageid"
|
|
|
|
// return "/%v/messages/%v"
|
|
|
|
// we don't care about performance here, it's prelisten.
|
|
|
|
func formatPath(path string) string {
|
|
|
|
if strings.Contains(path, ParamStart) || strings.Contains(path, WildcardParamStart) {
|
|
|
|
var (
|
|
|
|
startRune = ParamStart[0]
|
|
|
|
wildcardStartRune = WildcardParamStart[0]
|
|
|
|
)
|
|
|
|
|
|
|
|
var formattedParts []string
|
|
|
|
parts := strings.Split(path, "/")
|
|
|
|
for _, part := range parts {
|
|
|
|
if len(part) == 0 {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if part[0] == startRune || part[0] == wildcardStartRune {
|
|
|
|
// is param or wildcard param
|
|
|
|
part = "%v"
|
|
|
|
}
|
|
|
|
formattedParts = append(formattedParts, part)
|
|
|
|
}
|
|
|
|
|
|
|
|
return "/" + strings.Join(formattedParts, "/")
|
|
|
|
}
|
|
|
|
// the whole path is static just return it
|
|
|
|
return path
|
|
|
|
}
|
|
|
|
|
2017-08-24 14:40:06 +02:00
|
|
|
// StaticPath returns the static part of the original, registered route path.
|
|
|
|
// if /user/{id} it will return /user
|
|
|
|
// if /user/{id}/friend/{friendid:int} it will return /user too
|
|
|
|
// if /assets/{filepath:path} it will return /assets.
|
|
|
|
func (r Route) StaticPath() string {
|
|
|
|
src := r.tmpl.Src
|
|
|
|
bidx := strings.IndexByte(src, '{')
|
|
|
|
if bidx == -1 || len(src) <= bidx {
|
|
|
|
return src // no dynamic part found
|
|
|
|
}
|
|
|
|
if bidx == 0 { // found at first index,
|
|
|
|
// but never happens because of the prepended slash
|
|
|
|
return "/"
|
|
|
|
}
|
|
|
|
|
|
|
|
return src[:bidx]
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// ResolvePath returns the formatted path's %v replaced with the args.
|
|
|
|
func (r Route) ResolvePath(args ...string) string {
|
|
|
|
rpath, formattedPath := r.Path, r.FormattedPath
|
|
|
|
if rpath == formattedPath {
|
|
|
|
// static, no need to pass args
|
|
|
|
return rpath
|
|
|
|
}
|
|
|
|
// check if we have /*, if yes then join all arguments to one as path and pass that as parameter
|
|
|
|
if rpath[len(rpath)-1] == WildcardParamStart[0] {
|
|
|
|
parameter := strings.Join(args, "/")
|
|
|
|
return fmt.Sprintf(formattedPath, parameter)
|
|
|
|
}
|
|
|
|
// else return the formattedPath with its args,
|
|
|
|
// the order matters.
|
|
|
|
for _, s := range args {
|
|
|
|
formattedPath = strings.Replace(formattedPath, "%v", s, 1)
|
|
|
|
}
|
|
|
|
return formattedPath
|
|
|
|
}
|
2017-08-23 15:46:55 +02:00
|
|
|
|
2017-11-04 01:59:21 +01:00
|
|
|
// Trace returns some debug infos as a string sentence.
|
|
|
|
// Should be called after Build.
|
|
|
|
func (r Route) Trace() string {
|
|
|
|
printfmt := fmt.Sprintf("%s:", r.Method)
|
|
|
|
if r.Subdomain != "" {
|
|
|
|
printfmt += fmt.Sprintf(" %s", r.Subdomain)
|
|
|
|
}
|
|
|
|
printfmt += fmt.Sprintf(" %s ", r.Tmpl().Src)
|
|
|
|
if l := len(r.Handlers); l > 1 {
|
2017-12-04 04:06:03 +01:00
|
|
|
printfmt += fmt.Sprintf("-> %s() and %d more", r.MainHandlerName, l-1)
|
2017-11-04 01:59:21 +01:00
|
|
|
} else {
|
2017-12-04 04:06:03 +01:00
|
|
|
printfmt += fmt.Sprintf("-> %s()", r.MainHandlerName)
|
2017-11-04 01:59:21 +01:00
|
|
|
}
|
|
|
|
|
2017-12-04 04:06:03 +01:00
|
|
|
// printfmt := fmt.Sprintf("%s: %s >> %s", r.Method, r.Subdomain+r.Tmpl().Src, r.MainHandlerName)
|
2017-11-04 01:59:21 +01:00
|
|
|
// if l := len(r.Handlers); l > 0 {
|
|
|
|
// printfmt += fmt.Sprintf(" and %d more", l)
|
|
|
|
// }
|
|
|
|
return printfmt // without new line.
|
|
|
|
}
|
|
|
|
|
2017-08-23 15:46:55 +02:00
|
|
|
type routeReadOnlyWrapper struct {
|
|
|
|
*Route
|
|
|
|
}
|
|
|
|
|
2017-08-23 16:01:51 +02:00
|
|
|
func (rd routeReadOnlyWrapper) Method() string {
|
|
|
|
return rd.Route.Method
|
|
|
|
}
|
|
|
|
|
2017-08-23 15:46:55 +02:00
|
|
|
func (rd routeReadOnlyWrapper) Name() string {
|
|
|
|
return rd.Route.Name
|
|
|
|
}
|
|
|
|
|
|
|
|
func (rd routeReadOnlyWrapper) Subdomain() string {
|
|
|
|
return rd.Route.Subdomain
|
|
|
|
}
|
|
|
|
|
|
|
|
func (rd routeReadOnlyWrapper) Path() string {
|
|
|
|
return rd.Route.tmpl.Src
|
|
|
|
}
|
2017-11-04 01:59:21 +01:00
|
|
|
|
|
|
|
func (rd routeReadOnlyWrapper) Trace() string {
|
|
|
|
return rd.Route.Trace()
|
|
|
|
}
|