Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultErrStatusCode = 400
DefaultErrStatusCode is the default error status code (400) when the response contains an error which is not nil.
Functions ¶
func DispatchCommon ¶
func DispatchCommon(ctx context.Context, statusCode int, contentType string, content []byte, v interface{}, err error, found bool)
DispatchCommon is being used internally to send commonly used data to the response writer with a smart way.
func DispatchErr ¶
DispatchErr writes the error to the response.
func DispatchFuncResult ¶
DispatchFuncResult is being used internally to resolve and send the method function's output values to the context's response writer using a smart way which respects status code, content type, content, custom struct and an error type. Supports for: func(c *ExampleController) Get() string | (string, string) | (string, int) | ... int | (int, string | (string, error) | ... error | (int, error) | (customStruct, error) | ... bool | (int, bool) | (string, bool) | (customStruct, bool) | ... customStruct | (customStruct, int) | (customStruct, string) | Result or (Result, error) and so on...
where Get is an HTTP METHOD.
Types ¶
type FuncInfo ¶
type FuncInfo struct { // Name is the map function name. Name string // Trailing is not empty when the Name contains // characters after the titled method, i.e // if Name = Get -> empty // if Name = GetLogin -> Login // if Name = GetUserPost -> UserPost Trailing string // The Type of the method, includes the receivers. Type reflect.Type // Index is the index of this function inside the controller type. Index int // HTTPMethod is the original http method that this // function should be registered to and serve. // i.e "GET","POST","PUT"... HTTPMethod string }
FuncInfo is part of the `TController`, it contains the index for a specific http method, taken from user's controller struct.
type MethodFunc ¶
type MethodFunc struct { FuncInfo // MethodCall fires the actual handler. // The "ctx" is the current context, helps us to get any path parameter's values. // // The "f" is the controller's function which is responsible // for that request for this http method. // That function can accept one parameter. // // The default callers (and the only one for now) // are pre-calculated by the framework. MethodCall func(ctx context.Context, f reflect.Value) RelPath string }
MethodFunc the handler function.