Documentation ¶
Index ¶
- Variables
- func ParseParamType(value string, paramType ParamTypes, path string) (interface{}, error)
- type DWorkContext
- type HTTPVerb
- type InvalidHttpVerb
- type InvalidParamStruct
- type InvalidParamType
- type ParamTypes
- type ParamsConflict
- type PathAlreadyExist
- type RepeatedParameter
- type Route
- type RouteHandler
- type RouteParams
- type Routes
Constants ¶
This section is empty.
Variables ¶
var DEBUG_FLAG bool = false
Functions ¶
func ParseParamType ¶
func ParseParamType(value string, paramType ParamTypes, path string) (interface{}, error)
Types ¶
type DWorkContext ¶
type DWorkContext struct { Params RouteParams Response http.ResponseWriter Request *http.Request }
type InvalidHttpVerb ¶
type InvalidHttpVerb struct{}
func (InvalidHttpVerb) Error ¶
func (err InvalidHttpVerb) Error() string
type InvalidParamStruct ¶
func (InvalidParamStruct) Error ¶
func (err InvalidParamStruct) Error() string
type InvalidParamType ¶
func (InvalidParamType) Error ¶
func (err InvalidParamType) Error() string
type ParamTypes ¶
type ParamTypes string
const ( EMPTY ParamTypes = "" NULL ParamTypes = "NULL" STRING ParamTypes = "string" INT ParamTypes = "int" FLOAT ParamTypes = "float" BOOL ParamTypes = "bool" UUID ParamTypes = "uuid" )
func StringToParamType ¶
func StringToParamType(value string) ParamTypes
type ParamsConflict ¶
type ParamsConflict struct {
// contains filtered or unexported fields
}
func (ParamsConflict) Error ¶
func (err ParamsConflict) Error() string
type PathAlreadyExist ¶
type PathAlreadyExist struct {
// contains filtered or unexported fields
}
func (PathAlreadyExist) Error ¶
func (err PathAlreadyExist) Error() string
type RepeatedParameter ¶
type RepeatedParameter struct {
// contains filtered or unexported fields
}
func (RepeatedParameter) Error ¶
func (err RepeatedParameter) Error() string
type Route ¶
type Route struct { Kind string Path string Param string ParamType ParamTypes Handler RouteHandler Routes Routes }
type RouteHandler ¶
type RouteHandler func(DWorkContext)
type RouteParams ¶
type Routes ¶
func MakeRouter ¶
func MakeRouter() Routes
func (*Routes) Enable ¶
func (routes *Routes) Enable()
Enable enables the Routes.
It sets up the HTTP handler for the Routes. When a request comes in, it parses the route and parameters from the URL path and the request method.
If the route is not found or the corresponding handler is nil, it returns a 404 Not Found response.
If the route is found, it creates a DWorkContext with the parsed parameters, the response writer and the request, and passes it to the route's handler function.
func (*Routes) EnableDebug ¶
func (routes *Routes) EnableDebug()
EnableDebug enables the debug mode.
func (*Routes) RegisterRoute ¶
func (routes *Routes) RegisterRoute(verb HTTPVerb, path string, handler RouteHandler) error
RegisterRoute registers a new route in the Routes struct.
The function takes in the HTTPVerb, path, and handler as parameters.
It returns an error if there's an issue parsing the verb or if there are conflicts with the path or parameters.