Documentation ¶
Overview ¶
package turbo provides enterprise grade http routing capabilities
Index ¶
- Constants
- Variables
- func GetPathParam(id string, r *http.Request) (string, error)
- func GetPathParamAsBool(id string, r *http.Request) (bool, error)
- func GetPathParamAsFloat(id string, r *http.Request) (float64, error)
- func GetPathParamAsInt(id string, r *http.Request) (int, error)
- func GetQueryParam(id string, r *http.Request) (string, error)
- func GetQueryParamAsBool(id string, r *http.Request) (bool, error)
- func GetQueryParamAsFloat(id string, r *http.Request) (float64, error)
- func GetQueryParamAsInt(id string, r *http.Request) (int, error)
- type FilterFunc
- type Param
- type QueryParam
- type Route
- type Router
- func (router *Router) Add(path string, f func(w http.ResponseWriter, r *http.Request), methods ...string) (route *Route, err error)
- func (router *Router) AddCorsFilter(corsOpts *filters.CorsOptions) *Router
- func (router *Router) AddGlobalFilter(filter ...FilterFunc) *Router
- func (router *Router) AddHandler(path string, h http.Handler, methods ...string) (route *Route, err error)
- func (router *Router) Delete(path string, f func(w http.ResponseWriter, r *http.Request)) (*Route, error)
- func (router *Router) Get(path string, f func(w http.ResponseWriter, r *http.Request)) (*Route, error)
- func (router *Router) Post(path string, f func(w http.ResponseWriter, r *http.Request)) (*Route, error)
- func (router *Router) Put(path string, f func(w http.ResponseWriter, r *http.Request)) (*Route, error)
- func (router *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (r *Router) SetUnmanaged(handler http.Handler) *Router
- func (r *Router) SetUnsupportedMethod(handler http.Handler) *Router
Constants ¶
const ( PathSeparator = "/" GET = "GET" HEAD = "HEAD" POST = "POST" PUT = "PUT" DELETE = "DELETE" OPTIONS = "OPTIONS" TRACE = "TRACE" PATCH = "PATCH" )
Common constants used throughout
Variables ¶
var ErrInvalidHandler = errors.New("Invalid handler provided")
var ErrInvalidMethod = errors.New("Invalid method provided")
var ErrInvalidPath = errors.New("Invalid path provided")
Functions ¶
func GetPathParam ¶ added in v1.0.4
GetPathParam fetches the path parameters
func GetPathParamAsBool ¶ added in v1.0.4
GetPathParamAsBool fetches the bool path parameters
func GetPathParamAsFloat ¶ added in v1.0.4
GetPathParamAsFloat fetches the float path parameters
func GetPathParamAsInt ¶ added in v1.0.4
GetPathParamAsInt fetches the int path parameters
func GetQueryParam ¶ added in v1.0.4
GetQueryParam fetches the query parameters
func GetQueryParamAsBool ¶ added in v1.0.4
GetQueryParamAsBool fetches the boolean query parameters
func GetQueryParamAsFloat ¶ added in v1.0.4
GetQueryParamAsFloat fetches the float query parameters
Types ¶
type FilterFunc ¶
FilterFunc FuncHandler for with which the Filters need to be defined
type Param ¶
type Param struct {
// contains filtered or unexported fields
}
Param to hold key value
type QueryParam ¶
type QueryParam struct {
// contains filtered or unexported fields
}
QueryParam for the Route configuration
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
Route base struct to hold the route information
func (*Route) AddAuthenticator ¶
func (route *Route) AddAuthenticator(auth auth.Authenticator) *Route
AddAuthenticator Adding the authenticator filter to the route
func (*Route) AddFilter ¶
func (route *Route) AddFilter(filter ...FilterFunc) *Route
AddFilter Making the Filter Chain in the order of filters being added if f1, f2, f3, finalHandler handlers are added to the filter chain then the order of execution remains f1 -> f2 -> f3 -> finalHandler
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router struct that holds the router configuration
func NewRouter ¶
func NewRouter() *Router
NewRouter registers the new instance of the Turbo Framework
func (*Router) Add ¶
func (router *Router) Add(path string, f func(w http.ResponseWriter, r *http.Request), methods ...string) (route *Route, err error)
Add a turbo handler for one or more HTTP methods.
func (*Router) AddCorsFilter ¶ added in v1.0.6
func (router *Router) AddCorsFilter(corsOpts *filters.CorsOptions) *Router
func (*Router) AddGlobalFilter ¶ added in v1.0.6
func (router *Router) AddGlobalFilter(filter ...FilterFunc) *Router
AddGlobalFilter to add a global filter to the router
func (*Router) AddHandler ¶ added in v1.0.6
func (*Router) Delete ¶
func (router *Router) Delete(path string, f func(w http.ResponseWriter, r *http.Request)) (*Route, error)
Delete to Add a turbo handler for DELETE method
func (*Router) Get ¶
func (router *Router) Get(path string, f func(w http.ResponseWriter, r *http.Request)) (*Route, error)
Get to Add a turbo handler for GET method
func (*Router) Post ¶
func (router *Router) Post(path string, f func(w http.ResponseWriter, r *http.Request)) (*Route, error)
Post to Add a turbo handler for POST method
func (*Router) Put ¶
func (router *Router) Put(path string, f func(w http.ResponseWriter, r *http.Request)) (*Route, error)
Put to Add a turbo handler for PUT method
func (*Router) ServeHTTP ¶
func (router *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP