/vendor/github.com/webx-top/echo/echo_host.go
https://github.com/admpub/nging · Go · 43 lines · 41 code · 2 blank · 0 comment · 2 complexity · ea67ef666087f4e4b4919f93f7e33f51 MD5 · raw file
- package echo
- type (
- Host struct {
- head Handler
- group *Group
- groups map[string]*Group
- Router *Router
- }
- TypeHost struct {
- prefix string
- router *Router
- echo *Echo
- }
- )
- func (t TypeHost) URI(handler interface{}, params ...interface{}) string {
- if t.router == nil {
- return ``
- }
- return t.prefix + t.echo.URI(handler, params...)
- }
- func (h *Host) Host(args ...interface{}) (r TypeHost) {
- if h.group == nil || h.group.host == nil {
- return
- }
- r.echo = h.group.echo
- r.router = h.Router
- if len(args) != 1 {
- r.prefix = h.group.host.Format(args...)
- return
- }
- switch v := args[0].(type) {
- case map[string]interface{}:
- r.prefix = h.group.host.FormatMap(v)
- case H:
- r.prefix = h.group.host.FormatMap(v)
- default:
- r.prefix = h.group.host.Format(args...)
- }
- return
- }