Documentation ¶
Overview ¶
Package macross is a high productive and modular web framework in Golang.
Package macross is a high productive and modular web framework in Golang.
Index ¶
- Constants
- Variables
- func Config() *ini.File
- func GetAddress(args ...interface{}) string
- func MethodNotAllowedHandler(c *Context) error
- func NotFoundHandler(*Context) error
- func Serialize(data interface{}) (bytes []byte, err error)
- func SetConfig(source interface{}, others ...interface{}) (_ *ini.File, err error)
- func StatusText(code int) string
- type Args
- func (a *Args) Bytes() []byte
- func (a *Args) Exist() bool
- func (a *Args) Float32() (f float32, e error)
- func (a *Args) Float64() (f float64, e error)
- func (a *Args) Int() (int, error)
- func (a *Args) Int64() (int64, error)
- func (a *Args) MustFloat32() (f float32)
- func (a *Args) MustFloat64() (f float64)
- func (a *Args) MustInt() int
- func (a *Args) MustInt64() int64
- func (a *Args) MustUint() uint
- func (a *Args) MustUint8() uint8
- func (a *Args) String() string
- func (a *Args) Time() time.Time
- func (a *Args) ToSnakeCase(str ...string) string
- func (a *Args) ToStr(args ...int) (s string)
- type Binder
- type Context
- func (c *Context) Abort() error
- func (c *Context) Args(key ...string) *Args
- func (c *Context) Attachment(file, name string) (err error)
- func (c *Context) Bind(i interface{}) error
- func (c *Context) Blob(contentType string, b []byte, status ...int) (err error)
- func (c *Context) Body() io.Reader
- func (c *Context) Break(status int, err ...error) error
- func (c *Context) ContentLength() int64
- func (ctx *Context) ContentTypeByExtension(name string) (t string)
- func (ctx *Context) Cookie(name string) (*Cookie, error)
- func (ctx *Context) Cookies() []*Cookie
- func (c *Context) Data(data interface{}) (err error)
- func (c *Context) Form(key ...string) *Args
- func (c *Context) FormFile(name string) (*multipart.FileHeader, error)
- func (c *Context) FormParams() (params map[string][]string)
- func (c *Context) FormValue(name string) string
- func (c *Context) Get(name string) interface{}
- func (c *Context) GetStore() map[string]interface{}
- func (c *Context) GetURI() string
- func (c *Context) HTML(html string, status ...int) (err error)
- func (c *Context) Handler() Handler
- func (c *Context) Host() string
- func (c *Context) Inline(file, name string) (err error)
- func (c *Context) IsTLS() bool
- func (c *Context) JSON(i interface{}, status ...int) (err error)
- func (c *Context) JSONBlob(b []byte, status ...int) (err error)
- func (c *Context) JSONP(callback string, i interface{}, status ...int) (err error)
- func (c *Context) JSONPBlob(callback string, b []byte, status ...int) (err error)
- func (c *Context) JSONPretty(i interface{}, indent string, status ...int) (err error)
- func (c *Context) Kontext() ktx.Context
- func (c *Context) Macross() *Macross
- func (c *Context) Method() string
- func (c *Context) MultipartForm() (*multipart.Form, error)
- func (c *Context) Next() error
- func (c *Context) NoContent(status ...int) error
- func (c *Context) Param(name string) *Args
- func (c *Context) Parameter(i int) (value string)
- func (c *Context) QueryParam(name string) string
- func (c *Context) QueryParams() (params map[string][]string)
- func (c *Context) QueryString() string
- func (c *Context) RealIP() string
- func (c *Context) Redirect(url string, status ...int) error
- func (c *Context) Referer() string
- func (c *Context) RemoteAddress() string
- func (c *Context) Render(name string, status ...int) (err error)
- func (c *Context) RequestBody() io.Reader
- func (ctx *Context) RequestHeader(k string) string
- func (c *Context) Reset(ctx *fasthttp.RequestCtx)
- func (c *Context) Scheme() string
- func (ctx *Context) SendFile(filename string, destinationName string)
- func (ctx *Context) ServeContent(content io.ReadSeeker, filename string, modtime time.Time) error
- func (ctx *Context) ServeFile(file string) error
- func (c *Context) Set(name string, value interface{})
- func (c *Context) SetBody(reader io.Reader)
- func (ctx *Context) SetCookie(c *Cookie)
- func (c *Context) SetHandler(h Handler)
- func (c *Context) SetHost(host string)
- func (c *Context) SetKontext(ktx ktx.Context)
- func (c *Context) SetMethod(method string)
- func (c *Context) SetStore(data map[string]interface{})
- func (c *Context) SetURI(uri string)
- func (c *Context) Stream(contentType string, r io.Reader, status ...int) (err error)
- func (c *Context) String(s string, status ...int) (err error)
- func (c *Context) URL(route string, pairs ...interface{}) string
- func (c *Context) UserAgent() string
- func (c *Context) WrapAfterHandler(handler Handler) Handler
- func (c *Context) WrapBeforeHandler(handler Handler) Handler
- func (c *Context) XML(i interface{}, status ...int) (err error)
- func (c *Context) XMLBlob(b []byte, status ...int) (err error)
- func (c *Context) XMLPretty(i interface{}, indent string, status ...int) (err error)
- type Cookie
- func (c *Cookie) Domain() string
- func (c *Cookie) Expire() time.Time
- func (c *Cookie) HTTPOnly() bool
- func (c *Cookie) Name() string
- func (c *Cookie) Path() string
- func (c *Cookie) Secure() bool
- func (c *Cookie) SetDomain(domain string)
- func (c *Cookie) SetExpire(expire time.Time)
- func (c *Cookie) SetHTTPOnly(httpOnly bool)
- func (c *Cookie) SetName(name string)
- func (c *Cookie) SetPath(path string)
- func (c *Cookie) SetSecure(secure bool)
- func (c *Cookie) SetValue(value string)
- func (c *Cookie) Value() string
- type Flash
- type HTTPError
- type Handler
- type Localer
- type Macross
- func (m *Macross) AcquireContext() *Context
- func (m *Macross) Binder() Binder
- func (m *Macross) File(path, file string)
- func (m *Macross) HandleError(c *Context, err interface{})
- func (m *Macross) Listen(args ...interface{})
- func (m *Macross) ListenTLS(certFile, keyFile string, args ...interface{})
- func (m *Macross) ListenTLSEmbed(certData, keyData []byte, args ...interface{})
- func (m *Macross) Localer() Localer
- func (r *Macross) NotFound(handlers ...Handler)
- func (m *Macross) Pull(key string) interface{}
- func (m *Macross) Push(key string, value interface{})
- func (m *Macross) ReleaseContext(c *Context)
- func (r *Macross) Route(name string) *Route
- func (m *Macross) ServeHTTP(ctx *fasthttp.RequestCtx)
- func (m *Macross) Sessioner() Sessioner
- func (m *Macross) SetBinder(b Binder)
- func (m *Macross) SetLocaler(l Localer)
- func (m *Macross) SetRenderer(r Renderer)
- func (m *Macross) SetSessioner(s Sessioner)
- func (m *Macross) Static(prefix, root string)
- func (r *Macross) Use(handlers ...Handler)
- type RawStore
- type Renderer
- type Route
- func (r *Route) Connect(handlers ...Handler) *Route
- func (r *Route) Delete(handlers ...Handler) *Route
- func (r *Route) Get(handlers ...Handler) *Route
- func (r *Route) Head(handlers ...Handler) *Route
- func (r *Route) Name(name string) *Route
- func (r *Route) Options(handlers ...Handler) *Route
- func (r *Route) Patch(handlers ...Handler) *Route
- func (r *Route) Post(handlers ...Handler) *Route
- func (r *Route) Put(handlers ...Handler) *Route
- func (r *Route) To(methods string, handlers ...Handler) *Route
- func (r *Route) Trace(handlers ...Handler) *Route
- func (r *Route) URL(pairs ...interface{}) (s string)
- type RouteGroup
- func (r *RouteGroup) Any(path string, handlers ...Handler) *Route
- func (r *RouteGroup) Connect(path string, handlers ...Handler) *Route
- func (r *RouteGroup) Delete(path string, handlers ...Handler) *Route
- func (r *RouteGroup) Get(path string, handlers ...Handler) *Route
- func (r *RouteGroup) Group(prefix string, handlers ...Handler) *RouteGroup
- func (r *RouteGroup) Head(path string, handlers ...Handler) *Route
- func (r *RouteGroup) Options(path string, handlers ...Handler) *Route
- func (r *RouteGroup) Patch(path string, handlers ...Handler) *Route
- func (r *RouteGroup) Post(path string, handlers ...Handler) *Route
- func (r *RouteGroup) Put(path string, handlers ...Handler) *Route
- func (r *RouteGroup) To(methods, path string, handlers ...Handler) *Route
- func (r *RouteGroup) Trace(path string, handlers ...Handler) *Route
- func (r *RouteGroup) Use(handlers ...Handler)
- type SerializeFunc
- type Sessioner
Constants ¶
const ( CONNECT = "CONNECT" DELETE = "DELETE" GET = "GET" HEAD = "HEAD" OPTIONS = "OPTIONS" PATCH = "PATCH" POST = "POST" PUT = "PUT" TRACE = "TRACE" )
Export HTTP methods
const ( MIMEApplicationJSON = "application/json" MIMEApplicationJSONCharsetUTF8 = MIMEApplicationJSON + "; " + charsetUTF8 MIMEApplicationJavaScript = "application/javascript" MIMEApplicationJavaScriptCharsetUTF8 = MIMEApplicationJavaScript + "; " + charsetUTF8 MIMEApplicationXML = "application/xml" MIMEApplicationXMLCharsetUTF8 = MIMEApplicationXML + "; " + charsetUTF8 MIMEApplicationForm = "application/x-www-form-urlencoded" MIMEApplicationProtobuf = "application/protobuf" MIMEApplicationMsgpack = "application/msgpack" MIMETextHTML = "text/html" MIMETextHTMLCharsetUTF8 = MIMETextHTML + "; " + charsetUTF8 MIMETextPlain = "text/plain" MIMETextPlainCharsetUTF8 = MIMETextPlain + "; " + charsetUTF8 MIMEMultipartForm = "multipart/form-data" MIMEOctetStream = "application/octet-stream" )
MIME types
const ( HeaderAcceptEncoding = "Accept-Encoding" HeaderAllow = "Allow" HeaderAuthorization = "Authorization" HeaderContentDisposition = "Content-Disposition" HeaderContentEncoding = "Content-Encoding" HeaderContentLength = "Content-Length" HeaderContentType = "Content-Type" HeaderCookie = "Cookie" HeaderSetCookie = "Set-Cookie" HeaderIfModifiedSince = "If-Modified-Since" HeaderLastModified = "Last-Modified" HeaderLocation = "Location" HeaderUpgrade = "Upgrade" HeaderVary = "Vary" HeaderWWWAuthenticate = "WWW-Authenticate" HeaderXForwardedProto = "X-Forwarded-Proto" HeaderXHTTPMethodOverride = "X-HTTP-Method-Override" HeaderXForwardedFor = "X-Forwarded-For" HeaderXRealIP = "X-Real-IP" HeaderServer = "Server" HeaderOrigin = "Origin" HeaderAccessControlRequestMethod = "Access-Control-Request-Method" HeaderAccessControlRequestHeaders = "Access-Control-Request-Headers" HeaderAccessControlAllowOrigin = "Access-Control-Allow-Origin" HeaderAccessControlAllowMethods = "Access-Control-Allow-Methods" HeaderAccessControlAllowHeaders = "Access-Control-Allow-Headers" HeaderAccessControlAllowCredentials = "Access-Control-Allow-Credentials" HeaderAccessControlExposeHeaders = "Access-Control-Expose-Headers" HeaderAccessControlMaxAge = "Access-Control-Max-Age" // Security HeaderStrictTransportSecurity = "Strict-Transport-Security" HeaderXContentTypeOptions = "X-Content-Type-Options" HeaderXXSSProtection = "X-XSS-Protection" HeaderXFrameOptions = "X-Frame-Options" HeaderContentSecurityPolicy = "Content-Security-Policy" HeaderXCSRFToken = "X-CSRF-Token" )
Headers
const ( StatusContinue = 100 // RFC 7231, 6.2.1 StatusSwitchingProtocols = 101 // RFC 7231, 6.2.2 StatusProcessing = 102 // RFC 2518, 10.1 StatusOK = 200 // RFC 7231, 6.3.1 StatusCreated = 201 // RFC 7231, 6.3.2 StatusAccepted = 202 // RFC 7231, 6.3.3 StatusNonAuthoritativeInfo = 203 // RFC 7231, 6.3.4 StatusNoContent = 204 // RFC 7231, 6.3.5 StatusResetContent = 205 // RFC 7231, 6.3.6 StatusPartialContent = 206 // RFC 7233, 4.1 StatusMultiStatus = 207 // RFC 4918, 11.1 StatusAlreadyReported = 208 // RFC 5842, 7.1 StatusIMUsed = 226 // RFC 3229, 10.4.1 StatusMultipleChoices = 300 // RFC 7231, 6.4.1 StatusMovedPermanently = 301 // RFC 7231, 6.4.2 StatusFound = 302 // RFC 7231, 6.4.3 StatusSeeOther = 303 // RFC 7231, 6.4.4 StatusNotModified = 304 // RFC 7232, 4.1 StatusUseProxy = 305 // RFC 7231, 6.4.5 StatusTemporaryRedirect = 307 // RFC 7231, 6.4.7 StatusPermanentRedirect = 308 // RFC 7538, 3 StatusBadRequest = 400 // RFC 7231, 6.5.1 StatusPaymentRequired = 402 // RFC 7231, 6.5.2 StatusForbidden = 403 // RFC 7231, 6.5.3 StatusNotFound = 404 // RFC 7231, 6.5.4 StatusMethodNotAllowed = 405 // RFC 7231, 6.5.5 StatusNotAcceptable = 406 // RFC 7231, 6.5.6 StatusProxyAuthRequired = 407 // RFC 7235, 3.2 StatusRequestTimeout = 408 // RFC 7231, 6.5.7 StatusConflict = 409 // RFC 7231, 6.5.8 StatusGone = 410 // RFC 7231, 6.5.9 StatusLengthRequired = 411 // RFC 7231, 6.5.10 StatusPreconditionFailed = 412 // RFC 7232, 4.2 StatusRequestEntityTooLarge = 413 // RFC 7231, 6.5.11 StatusRequestURITooLong = 414 // RFC 7231, 6.5.12 StatusUnsupportedMediaType = 415 // RFC 7231, 6.5.13 StatusRequestedRangeNotSatisfiable = 416 // RFC 7233, 4.4 StatusExpectationFailed = 417 // RFC 7231, 6.5.14 StatusTeapot = 418 // RFC 7168, 2.3.3 StatusUnprocessableEntity = 422 // RFC 4918, 11.2 StatusLocked = 423 // RFC 4918, 11.3 StatusFailedDependency = 424 // RFC 4918, 11.4 StatusUpgradeRequired = 426 // RFC 7231, 6.5.15 StatusPreconditionRequired = 428 // RFC 6585, 3 StatusTooManyRequests = 429 // RFC 6585, 4 StatusRequestHeaderFieldsTooLarge = 431 // RFC 6585, 5 StatusInternalServerError = 500 // RFC 7231, 6.6.1 StatusNotImplemented = 501 // RFC 7231, 6.6.2 StatusBadGateway = 502 // RFC 7231, 6.6.3 StatusGatewayTimeout = 504 // RFC 7231, 6.6.5 StatusHTTPVersionNotSupported = 505 // RFC 7231, 6.6.6 StatusVariantAlsoNegotiates = 506 // RFC 2295, 8.1 StatusInsufficientStorage = 507 // RFC 4918, 11.5 StatusLoopDetected = 508 // RFC 5842, 7.2 StatusNotExtended = 510 // RFC 2774, 7 StatusNetworkAuthenticationRequired = 511 // RFC 6585, 6 )
Status HTTP status codes as registered with IANA. See: http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
const TimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT"
TimeFormat is the time format to use when generating times in HTTP headers. It is like time.RFC1123 but hard-codes GMT as the time zone. The time being formatted must be in UTC for Format to generate the correct format.
For parsing this time format, see ParseTime.
Variables ¶
var ( ErrUnsupportedMediaType = NewHTTPError(StatusUnsupportedMediaType) ErrNotFound = NewHTTPError(StatusNotFound) ErrStatusBadRequest = NewHTTPError(StatusBadRequest) ErrMethodNotAllowed = NewHTTPError(StatusMethodNotAllowed) ErrStatusRequestEntityTooLarge = NewHTTPError(StatusRequestEntityTooLarge) ErrRendererNotRegistered = errors.New("renderer not registered") ErrInvalidRedirectCode = errors.New("invalid redirect status code") ErrCookieNotFound = errors.New("cookie not found") )
Errors
var ( // Flash applies to current request. FlashNow bool )
Functions ¶
func Config ¶
func Config() *ini.File
Config returns configuration convention object. It returns an empty object if there is no one available.
func GetAddress ¶
func GetAddress(args ...interface{}) string
func MethodNotAllowedHandler ¶
MethodNotAllowedHandler handles the situation when a request has matching route without matching HTTP method. In this case, the handler will respond with an Allow HTTP header listing the allowed HTTP methods. Otherwise, the handler will do nothing and let the next handler (usually a NotFoundHandler) to handle the problem.
func NotFoundHandler ¶
NotFoundHandler returns a 404 HTTP error indicating a request has no matching route.
func Serialize ¶
Serialize converts the given data into a byte array. If the data is neither a byte array nor a string, it will call fmt.Sprint to convert it into a string.
func SetConfig ¶
func SetConfig(source interface{}, others ...interface{}) (_ *ini.File, err error)
SetConfig sets data sources for configuration.
func StatusText ¶
StatusText returns a text for the HTTP status code. It returns the empty string if the code is unknown.
Types ¶
type Args ¶
type Args struct {
// contains filtered or unexported fields
}
func (*Args) MustFloat32 ¶
func (*Args) MustFloat64 ¶
func (*Args) ToSnakeCase ¶
type Context ¶
type Context struct { *fasthttp.RequestCtx Serialize SerializeFunc // the function serializing the given data of arbitrary type into a byte array. Session Sessioner Localer Flash *Flash // contains filtered or unexported fields }
Context represents the contextual data and environment while processing an incoming HTTP request.
func (*Context) Abort ¶
Abort skips the rest of the handlers associated with the current route. Abort is normally used when a handler handles the request normally and wants to skip the rest of the handlers. If a handler wants to indicate an error condition, it should simply return the error without calling Abort.
func (*Context) Attachment ¶
func (*Context) ContentLength ¶
ContentLength implements `Context#ContentLength` function.
func (*Context) ContentTypeByExtension ¶
ContentTypeByExtension returns the MIME type associated with the file based on its extension. It returns `application/octet-stream` incase MIME type is not found.
func (*Context) Data ¶
Data writes the given data of arbitrary type to the response. The method calls the Serialize() method to convert the data into a byte array and then writes the byte array to the response.
func (*Context) FormFile ¶
func (c *Context) FormFile(name string) (*multipart.FileHeader, error)
FormFile implements `Context#FormFile` function.
func (*Context) FormParams ¶
FormParams implements `Context#FormParams` function.
func (*Context) Get ¶
Get returns the named data item previously registered with the context by calling Set. If the named data item cannot be found, nil will be returned.
func (*Context) JSONPretty ¶
func (*Context) MultipartForm ¶
MultipartForm implements `Context#MultipartForm` function.
func (*Context) Next ¶
Next calls the rest of the handlers associated with the current route. If any of these handlers returns an error, Next will return the error and skip the following handlers. Next is normally used when a handler needs to do some postprocessing after the rest of the handlers are executed.
func (*Context) Param ¶
Param returns the named parameter value that is found in the URL path matching the current route. If the named parameter cannot be found, an empty string will be returned.
func (*Context) QueryParam ¶
QueryParam implements `Context#QueryParam` function.
func (*Context) QueryParams ¶
QueryParams implements `Context#QueryParams` function.
func (*Context) QueryString ¶
func (*Context) RemoteAddress ¶
RemoteAddress implements `Context#RemoteAddress` function.
func (*Context) RequestBody ¶
func (*Context) RequestHeader ¶
RequestHeader returns the request header's value accepts one parameter, the key of the header (string) returns string
func (*Context) Reset ¶
func (c *Context) Reset(ctx *fasthttp.RequestCtx)
Reset sets the request and response of the context and resets all other properties.
func (*Context) SendFile ¶
SendFile sends file for force-download to the client
Use this instead of ServeFile to 'force-download' bigger files to the client
func (*Context) ServeContent ¶
ServeContent serves content, headers are autoset receives three parameters, it's low-level function, instead you can use .ServeFile(string,bool)/SendFile(string,string)
You can define your own "Content-Type" header also, after this function call Doesn't implements resuming (by range), use ctx.SendFile instead
func (*Context) ServeFile ¶
ServeFile serves a view file, to send a file ( zip for example) to the client you should use the SendFile(serverfilename,clientfilename)
You can define your own "Content-Type" header also, after this function call This function doesn't implement resuming (by range), use ctx.SendFile/fasthttp.ServeFileUncompressed(ctx.RequestCtx,path)/fasthttpServeFile(ctx.RequestCtx,path) instead
Use it when you want to serve css/js/... files to the client, for bigger files and 'force-download' use the SendFile
func (*Context) Set ¶
Set stores the named data item in the context so that it can be retrieved later.
func (*Context) SetHandler ¶
func (*Context) SetKontext ¶
func (*Context) URL ¶
URL creates a URL using the named route and the parameter values. The parameters should be given in the sequence of name1, value1, name2, value2, and so on. If a parameter in the route is not provided a value, the parameter token will remain in the resulting URL. Parameter values will be properly URL encoded. The method returns an empty string if the URL creation fails.
func (*Context) WrapAfterHandler ¶
func (*Context) WrapBeforeHandler ¶
type Cookie ¶
Cookie implements `Cookie`.
func (*Cookie) SetHTTPOnly ¶
SetHTTPOnly sets the cookie as HTTPOnly.
type Flash ¶
type HTTPError ¶
type HTTPError struct { Status int //`json:"status" xml:"status"` Message string //`json:"message" xml:"message"` }
Error contains the error information reported by calling Context.Error(). HTTPError represents an error that occurred while handling a request.
func NewHTTPError ¶
NewHTTPError creates a new HTTPError instance.
func (*HTTPError) StatusCode ¶
StatusCode returns the HTTP status code.
type Handler ¶
Handler is the function for handling HTTP requests.
func WrapFastHandler ¶
func WrapFastHandler(handler fasthttp.RequestHandler) Handler
WrapHandler wraps `fasthttp.RequestHandler` into `macross.Handler`.
func WrapHttpHandler ¶
WrapHttpHandler is responsible for adapting macross requests through fasthttp interfaces to net/http requests.
Based on valyala/fasthttp implementation. Available here: https://github.com/valyala/fasthttp/blob/master/fasthttpadaptor/adaptor.go
type Macross ¶
type Macross struct { RouteGroup // contains filtered or unexported fields }
Macross manages routes and dispatches HTTP requests to the handlers of the matching routes.
func (*Macross) AcquireContext ¶
AcquireContext returns an empty `Context` instance from the pool. You must return the context by calling `ReleaseContext()`.
func (*Macross) HandleError ¶
HandleError is the error handler for handling any unhandled errors.
func (*Macross) ListenTLSEmbed ¶
func (*Macross) NotFound ¶
NotFound specifies the handlers that should be invoked when the macross cannot find any route matching a request. Note that the handlers registered via Use will be invoked first in this case.
func (*Macross) ReleaseContext ¶
ReleaseContext returns the `Context` instance back to the pool. You must call it after `AcquireContext()`.
func (*Macross) Route ¶
Route returns the named route. Nil is returned if the named route cannot be found.
func (*Macross) ServeHTTP ¶
func (m *Macross) ServeHTTP(ctx *fasthttp.RequestCtx)
ServeHTTP handles the HTTP request.
func (*Macross) SetLocaler ¶
SetLocale registers a custom localer.
func (*Macross) SetRenderer ¶
SetRenderer registers an HTML template renderer. It's invoked by `Context#Render()`.
func (*Macross) SetSessioner ¶
SetSessioner registers a custom sessioner. It's invoked by `Context#Bind()`.
type RawStore ¶
type RawStore interface { // Set sets value to given key in session. Set(interface{}, interface{}) error // Get gets value by given key in session. Get(interface{}) interface{} // Delete deletes a key from session. Delete(interface{}) error // ID returns current session ID. ID() string // Release releases session resource and save data to provider. Release(*Context) error // Flush deletes all session data. Flush() error }
RawStore is the interface that operates the session data.
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
Route represents a URL path pattern that can be used to match requested URLs.
func (*Route) Name ¶
Name sets the name of the route. This method will update the registration of the route in the macross as well.
func (*Route) To ¶
To adds the route to the macross with the given HTTP methods and handlers. Multiple HTTP methods should be separated by commas (without any surrounding spaces).
func (*Route) URL ¶
URL creates a URL using the current route and the given parameters. The parameters should be given in the sequence of name1, value1, name2, value2, and so on. If a parameter in the route is not provided a value, the parameter token will remain in the resulting URL. The method will perform URL encoding for all given parameter values.
type RouteGroup ¶
type RouteGroup struct {
// contains filtered or unexported fields
}
RouteGroup represents a group of routes that share the same path prefix.
func (*RouteGroup) Any ¶
func (r *RouteGroup) Any(path string, handlers ...Handler) *Route
Any adds a route with the given route, handlers, and the HTTP methods as listed in routing.Methods.
func (*RouteGroup) Connect ¶
func (r *RouteGroup) Connect(path string, handlers ...Handler) *Route
Connect adds a CONNECT route to the macross with the given route path and handlers.
func (*RouteGroup) Delete ¶
func (r *RouteGroup) Delete(path string, handlers ...Handler) *Route
Delete adds a DELETE route to the macross with the given route path and handlers.
func (*RouteGroup) Get ¶
func (r *RouteGroup) Get(path string, handlers ...Handler) *Route
Get adds a GET route to the macross with the given route path and handlers.
func (*RouteGroup) Group ¶
func (r *RouteGroup) Group(prefix string, handlers ...Handler) *RouteGroup
Group creates a RouteGroup with the given route path prefix and handlers. The new group will combine the existing path prefix with the new one. If no handler is provided, the new group will inherit the handlers registered with the current group.
func (*RouteGroup) Head ¶
func (r *RouteGroup) Head(path string, handlers ...Handler) *Route
Head adds a HEAD route to the macross with the given route path and handlers.
func (*RouteGroup) Options ¶
func (r *RouteGroup) Options(path string, handlers ...Handler) *Route
Options adds an OPTIONS route to the macross with the given route path and handlers.
func (*RouteGroup) Patch ¶
func (r *RouteGroup) Patch(path string, handlers ...Handler) *Route
Patch adds a PATCH route to the macross with the given route path and handlers.
func (*RouteGroup) Post ¶
func (r *RouteGroup) Post(path string, handlers ...Handler) *Route
Post adds a POST route to the macross with the given route path and handlers.
func (*RouteGroup) Put ¶
func (r *RouteGroup) Put(path string, handlers ...Handler) *Route
Put adds a PUT route to the macross with the given route path and handlers.
func (*RouteGroup) To ¶
func (r *RouteGroup) To(methods, path string, handlers ...Handler) *Route
To adds a route to the macross with the given HTTP methods, route path, and handlers. Multiple HTTP methods should be separated by commas (without any surrounding spaces).
func (*RouteGroup) Trace ¶
func (r *RouteGroup) Trace(path string, handlers ...Handler) *Route
Trace adds a TRACE route to the macross with the given route path and handlers.
func (*RouteGroup) Use ¶
func (r *RouteGroup) Use(handlers ...Handler)
Use registers one or multiple handlers to the current route group. These handlers will be shared by all routes belong to this group and its subgroups.
type SerializeFunc ¶
SerializeFunc serializes the given data of arbitrary type into a byte array.
type Sessioner ¶
type Sessioner interface { RawStore //---------------------------------------------// // Read returns raw session store by session ID. Read(string) (RawStore, error) // Destory deletes a session. Destory(*Context) error // RegenerateId regenerates a session store from old session ID to new one. RegenerateId(*Context) (RawStore, error) // Count counts and returns number of sessions. Count() int // GC calls GC to clean expired sessions. GC() }
Sessioner is the interface that contains all data for one session process with specific ID.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package access provides an access logging handler for the macross package.
|
Package access provides an access logging handler for the macross package. |
libraries
|
|
com
Package com is an open source project for commonly used functions for the Go programming language.
|
Package com is an open source project for commonly used functions for the Go programming language. |
femplate
Package femplate implements simple and fast template library.
|
Package femplate implements simple and fast template library. |
i18n
Package i18n is for app Internationalization and Localization.
|
Package i18n is for app Internationalization and Localization. |
i18n/ui18n
ui18n is a helper tool for Unknwon/i18n package.
|
ui18n is a helper tool for Unknwon/i18n package. |
ini.v1
Package ini provides INI file read and write functionality in Go.
|
Package ini provides INI file read and write functionality in Go. |