Documentation ¶
Index ¶
- Constants
- Variables
- func Get() *router
- func New(controller AppController) *router
- func NewContext(ctx context.Context, header http.Header) *promise.Promise
- func NewHandler(route route, customRender JSONRender) *handler
- func NewLoggingResponseWriter(w http.ResponseWriter) *loggingResponseWriter
- func NewRender(ctx *Context, custom JSONRender) *promise.Promise
- func NewTree() *tree
- func SetJsonData(v interface{}, w http.ResponseWriter)
- func SetStatus(statusCode int, w http.ResponseWriter)
- type AppController
- type Context
- func (c *Context) GetBody() *io.ReadCloser
- func (c *Context) GetContext() *Context
- func (c *Context) GetContextData(key string) interface{}
- func (c *Context) GetFormValue(value string) string
- func (c *Context) GetHeader() http.Header
- func (c *Context) GetJSON() interface{}
- func (c *Context) GetLocale() string
- func (c *Context) GetMatchPath() string
- func (c *Context) GetMultiFormFormFile(value string) *multipart.FileHeader
- func (c *Context) GetMultiFormFormValue(value string) string
- func (c *Context) GetParam(name string) string
- func (c *Context) GetPath() string
- func (c *Context) GetProfils() []string
- func (c *Context) GetQuery() map[string][]string
- func (c *Context) GetQueryParams() params
- func (c *Context) GetRemoteIP() string
- func (c *Context) GetRemoteURI() string
- func (c *Context) GetResponseWriter() http.ResponseWriter
- func (c *Context) GetURL() (url *url.URL)
- func (c *Context) GetUUID() string
- func (c *Context) IsFinish() bool
- func (c *Context) JSON(statusCode int, data interface{})
- func (c *Context) ParseBody(v interface{}) (err error)
- func (c *Context) RequireBody(typeBody int) (err error)
- func (c *Context) Response() interface{}
- func (c *Context) SetContextData(key string, data interface{})
- func (c *Context) SetForm(form url.Values)
- func (c *Context) SetHeader(key string, value string)
- func (c *Context) SetJSON(body io.ReadCloser)
- func (c *Context) SetLocale(language string)
- func (c *Context) SetMatchPath(path string)
- func (c *Context) SetMultiPartForm(multipartForm *multipart.Form)
- func (c *Context) SetProfils(profils []string)
- func (c *Context) SetQuery(query map[string][]string, params params, path string)
- func (c *Context) SetRemote(ip string, uri string)
- func (c *Context) SetRequestHeader(values http.Header)
- func (c *Context) SetURL(url *url.URL)
- func (c *Context) SetXML(body io.ReadCloser)
- func (c *Context) StatusCode() int
- type ContextLast
- type ErrorMsg
- type ErrorStackTrace
- type HTTPError
- func (e *HTTPError) Code() string
- func (e *HTTPError) Details() interface{}
- func (e *HTTPError) Error() string
- func (e *HTTPError) Message() string
- func (e *HTTPError) OnDev() bool
- func (e *HTTPError) SetCode(code string) *HTTPError
- func (e *HTTPError) SetDetails(details interface{}) *HTTPError
- func (e *HTTPError) SetMessage(message string) *HTTPError
- func (e *HTTPError) SetOnDev(private bool) *HTTPError
- func (e *HTTPError) SetStatusCode(statusCode int) *HTTPError
- func (e *HTTPError) SetTrace(trace string) *HTTPError
- func (e *HTTPError) StatusCode() int
- func (e *HTTPError) Trace() []string
- type HTTPGenericError
- type Handler
- type HandlerFunc
- type JSONRender
- type Middleware
- type NextHandler
- type R
- type Render
- type Route
- type Router
Constants ¶
View Source
const ( BODY_UNKNOWN = iota BODY_JSON = 1 BODY_MUTLIPART_FORM = 2 BODY_FORM = 3 BODY_FILE = 4 BODY_XML = 5 DEFAULT_LOCALE = "fr_FR" )
View Source
const ( TYPE_NONE = iota TYPE_QUERY = "query" TYPE_JSON = "json" TYPE_FORM = "form" TYPE_MULTI_PART = "multipart" TYPE_MULTI_PART_FILE = "multipart-file" TYPE_FILE = "file" ERROR_INVOKE_MIDDLEWARE = "%s middleware method not found" )
View Source
const ( ENV_PRODUCTION = "PROD" API_INTERNAL_ERROR = "API_INTERNAL_ERROR" API_INVOKE_ERROR = "API_INVOKE_ERROR" API_BODY_JSON_PARSE_FAIL = "API_BODY_JSON_PARSE_FAIL" API_BODY_XML_PARSE_FAIL = "API_BODY_XML_PARSE_FAIL" API_BODY_EOF = "API_BODY_EOF" API_BODY_TOO_LARGE = "API_BODY_TOO_LARGE" API_BODY_FORM_EMPTY = "API_BODY_FORM_EMPTY" API_BODY_FORM_DATA_EMPTY = "API_BODY_FORM_DATA_EMPTY" API_BODY_JSON_TYPE_FAIL = "API_BODY_JSON_TYPE_FAIL" API_BODY_XML_TYPE_FAIL = "API_BODY_XML_TYPE_FAIL" API_BODY_TYPE_FAIL = "API_BODY_TYPE_FAIL" API_BODY_VALIDATOR_FAIL = "API_BODY_VALIDATOR_FAIL" API_QUERY_VALIDATOR_FAIL = "API_QUERY_VALIDATOR_FAIL" API_FORM_VALIDATOR_FAIL = "API_FORM_VALIDATOR_FAIL" API_EXCEEDED_TIMEOUT = "API_EXCEEDED_TIMEOUT" )
noinspection ALL
View Source
const NAMESPACE = "router"
View Source
const ( // ParamsKey is the key in a request context. ParamsKey key = iota )
Variables ¶
View Source
var ( // Error for not found. ErrNotFound = errors.New("no matching route was found") // Error for method not allowed. ErrMethodNotAllowed = errors.New("methods is not allowed") // Configurable Handler to be used when no route matches. NotFoundHandler http.Handler // Configurable Handler to be used when the request method does not match the route. MethodNotAllowedHandler http.Handler )
Functions ¶
func New ¶
func New(controller AppController) *router
func NewHandler ¶
func NewHandler(route route, customRender JSONRender) *handler
func NewLoggingResponseWriter ¶
func NewLoggingResponseWriter(w http.ResponseWriter) *loggingResponseWriter
func SetJsonData ¶
func SetJsonData(v interface{}, w http.ResponseWriter)
func SetStatus ¶
func SetStatus(statusCode int, w http.ResponseWriter)
Types ¶
type AppController ¶
type Context ¶
func (*Context) GetBody ¶
func (c *Context) GetBody() *io.ReadCloser
func (*Context) GetContext ¶
func (*Context) GetContextData ¶
func (*Context) GetFormValue ¶
func (*Context) GetMatchPath ¶
func (*Context) GetMultiFormFormFile ¶
func (c *Context) GetMultiFormFormFile(value string) *multipart.FileHeader
func (*Context) GetMultiFormFormValue ¶
func (*Context) GetProfils ¶
func (*Context) GetQueryParams ¶
func (c *Context) GetQueryParams() params
func (*Context) GetRemoteIP ¶
func (*Context) GetRemoteURI ¶
func (*Context) GetResponseWriter ¶
func (c *Context) GetResponseWriter() http.ResponseWriter
func (*Context) RequireBody ¶
func (*Context) SetContextData ¶
func (*Context) SetJSON ¶
func (c *Context) SetJSON(body io.ReadCloser)
func (c *Context) SetFile(body io.ReadCloser) { c.file = new(File) c.file.data = body c._setTypeBody(BODY_FILE) }
func (*Context) SetMatchPath ¶
func (*Context) SetMultiPartForm ¶
func (*Context) SetProfils ¶
func (*Context) SetRequestHeader ¶
func (*Context) SetXML ¶
func (c *Context) SetXML(body io.ReadCloser)
func (*Context) StatusCode ¶
type ErrorStackTrace ¶
type HTTPError ¶
type HTTPError struct {
// contains filtered or unexported fields
}
func HTTPBadRequest ¶
func HTTPBadRequest() *HTTPError
func HTTPInternalServerError ¶
func HTTPInternalServerError() *HTTPError
func HTTPRequestTimeout ¶
func HTTPRequestTimeout() *HTTPError
func HTTPUnauthorized ¶
func HTTPUnauthorized() *HTTPError
func NewHTTPError ¶
func (*HTTPError) SetDetails ¶
func (*HTTPError) SetMessage ¶
func (*HTTPError) SetStatusCode ¶
func (*HTTPError) StatusCode ¶
type HTTPGenericError ¶
type HandlerFunc ¶
func (HandlerFunc) Next ¶
func (h HandlerFunc) Next(c *Context) (err error)
type JSONRender ¶
type Middleware ¶
type Middleware struct { }
func (*Middleware) Helmet ¶
func (m *Middleware) Helmet() func(h Handler) Handler
func (*Middleware) ResponseTime ¶
func (m *Middleware) ResponseTime(data struct { Render string `json:"render"` }) func(h Handler) Handler
type NextHandler ¶
func (NextHandler) Next ¶
func (n NextHandler) Next(c *Context) (err error)
type Render ¶
type Render struct {
// contains filtered or unexported fields
}
func (*Render) GetContext ¶
func (*Render) SetContext ¶
func (*Render) SetRequest ¶
func (*Render) SetResponseWriter ¶
func (r *Render) SetResponseWriter(w http.ResponseWriter) *promise.Promise
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
route represents the route which has data for a routing.
Click to show internal directories.
Click to hide internal directories.