Router

func RouterFilter

func RouterFilter(c *Controller, fc []Filter)

type ActionDefinition

type ActionDefinition struct {
    Host, Method, Url, Action string
    Star                      bool
    Args                      map[string]string
}

func (*ActionDefinition) String

func (a *ActionDefinition) String() string

type Route

type Route struct {
    Method         string   // e.g. GET
    Path           string   // e.g. /app/:id
    Action         string   // e.g. "Application.ShowApp", "404"
    ControllerName string   // e.g. "Application", ""
    MethodName     string   // e.g. "ShowApp", ""
    FixedParams    []string // e.g. "arg1","arg2","arg3" (CSV formatting)
    TreePath       string   // e.g. "/GET/app/:id"
    // contains filtered or unexported fields
}

func NewRoute

func NewRoute(method, path, action, fixedArgs, routesPath string, line int) (r *Route)

Prepares the route to be used in matching.

type RouteMatch

type RouteMatch struct {
    Action         string // e.g. 404
    ControllerName string // e.g. Application
    MethodName     string // e.g. ShowApp
    FixedParams    []string
    Params         map[string][]string // e.g. {id: 123}
}

type Router

type Router struct {
    Routes []*Route
    Tree   *pathtree.Node
    // contains filtered or unexported fields
}

func NewRouter

func NewRouter(routesPath string) *Router

func (*Router) Refresh

func (router *Router) Refresh() (err *Error)

Refresh re-reads the routes file and re-calculates the routing table. Returns an error if a specified action could not be found.

func (*Router) Reverse

func (router *Router) Reverse(action string, argValues map[string]string) *ActionDefinition

func (*Router) Route

func (router *Router) Route(req *http.Request) *RouteMatch