Documentation
¶
Index ¶
- Constants
- Variables
- func Version() string
- type Context
- func (c *Context) Abort()
- func (c *Context) ClientIP() string
- func (c *Context) Get(key string) (interface{}, error)
- func (ctx *Context) GetBasicSecureCookie(Secret, name string) (string, bool)
- func (c *Context) GetCookie(name string) string
- func (ctx *Context) GetSecureCookie(name string) (string, bool)
- func (c *Context) Json(data interface{}, status ...int)
- func (c *Context) Jsonp(callback string, data interface{}, status ...int)
- func (c *Context) MustGet(key string) interface{}
- func (c *Context) Next()
- func (c *Context) Redirect(location string, status ...int)
- func (c *Context) Set(key string, item interface{})
- func (ctx *Context) SetBasicSecureCookie(Secret, name, value string, others ...interface{})
- func (c *Context) SetCookie(name, value string, others ...interface{})
- func (c *Context) SetHeader(key, value string)
- func (ctx *Context) SetSecureCookie(name, value string, others ...interface{})
- func (c *Context) Text(data string, status ...int)
- func (c *Context) Xml(data interface{}, status ...int)
- type Engine
- type HandlerFunc
- type HtmlEngine
- type JSON
- type ResponseWriter
- type RouterGroup
- func (c *RouterGroup) Any(relativePath string, handlers ...HandlerFunc)
- func (c *RouterGroup) DELETE(relativePath string, handlers ...HandlerFunc)
- func (c *RouterGroup) GET(relativePath string, handlers ...HandlerFunc)
- func (c *RouterGroup) Group(relativePath string, fn func(*RouterGroup), handlers ...HandlerFunc) *RouterGroup
- func (c *RouterGroup) HEAD(relativePath string, handlers ...HandlerFunc)
- func (c *RouterGroup) Handle(httpMethod, relativePath string, handlers []HandlerFunc)
- func (c *RouterGroup) OPTIONS(relativePath string, handlers ...HandlerFunc)
- func (c *RouterGroup) PATCH(relativePath string, handlers ...HandlerFunc)
- func (c *RouterGroup) POST(relativePath string, handlers ...HandlerFunc)
- func (c *RouterGroup) PUT(relativePath string, handlers ...HandlerFunc)
- func (c *RouterGroup) Static(path, dir string)
- func (c *RouterGroup) Use(middlewares ...HandlerFunc)
- type Session
- type SessionOptions
- type SessionStore
Constants ¶
const ( DEV string = "development" PROD string = "production" TEST string = "test" )
Variables ¶
var NekoEnv = DEV
NekoEnv is the environment that Neko is executing in. The NEKO_ENV is read on initialization to set this variable.
Functions ¶
Types ¶
type Context ¶
type Context struct { Writer ResponseWriter Req *http.Request Session Session Keys map[string]interface{} Params routerParams Engine *Engine HtmlEngine // contains filtered or unexported fields }
func (*Context) Abort ¶
func (c *Context) Abort()
Forces the system to do not continue calling the pending handlers in the chain.
func (*Context) Get ¶
Get returns the value for the given key or an error if the key does not exist.
func (*Context) GetBasicSecureCookie ¶
GetBasicSecureCookie returns given cookie value from request header with secret string.
func (*Context) GetSecureCookie ¶
GetSecureCookie returns given cookie value from request header with default secret string.
func (*Context) Json ¶
Serializes the given struct as JSON into the response body in a fast and efficient way. It also sets the Content-Type as "application/json".
func (*Context) Jsonp ¶
Serializes the given struct as JSONP into the response body in a fast and efficient way. It also sets the Content-Type as "application/javascript".
func (*Context) MustGet ¶
MustGet returns the value for the given key or panics if the value doesn't exist.
func (*Context) Next ¶
func (c *Context) Next()
Next should be used only in the middlewares. It executes the pending handlers in the chain inside the calling handler.
func (*Context) Redirect ¶
Redirect returns a HTTP redirect to the specific location. default for 302
func (*Context) SetBasicSecureCookie ¶
SetBasicSecureCookie sets given cookie value to response header with secret string.
func (*Context) SetCookie ¶
SetCookie sets given cookie value to response header. ctx.SetCookie(name, value [, MaxAge, Path, Domain, Secure, HttpOnly])
func (*Context) SetSecureCookie ¶
SetSecureCookie sets given cookie value to response header with default secret string.
type Engine ¶
type Engine struct { *RouterGroup AppName string // contains filtered or unexported fields }
func Classic ¶
Classic creates a classic Neko with some basic default middleware - neko.Logger and neko.Recovery.
func New ¶
func New() *Engine
New returns a new blank Engine instance without any middleware attached.
func (*Engine) ServeHTTP ¶
func (c *Engine) ServeHTTP(res http.ResponseWriter, req *http.Request)
ServeHTTP makes the router implement the http.Handler interface.
func (*Engine) SetCookieSecret ¶
SetCookieSecret sets global default secure cookie secret.
func (*Engine) Use ¶
func (c *Engine) Use(middlewares ...HandlerFunc)
type HandlerFunc ¶
type HandlerFunc func(*Context)
func Logger ¶
func Logger() HandlerFunc
func Recovery ¶
func Recovery() HandlerFunc
Recovery returns a middleware that recovers from any panics and writes a 500 if there was one.
type HtmlEngine ¶
HtmlEngine is an interface for parsing html templates and redering HTML.
type ResponseWriter ¶
type ResponseWriter interface { http.ResponseWriter http.Flusher Status() int // Size returns the size of the response body. Size() int Written() bool WriteHeaderNow() // Before allows for a function to be called before the ResponseWriter has been written to. This is // useful for setting headers or any other operations that must happen before a response has been written. Before(func(ResponseWriter)) }
type RouterGroup ¶
type RouterGroup struct { Handlers []HandlerFunc // contains filtered or unexported fields }
func (*RouterGroup) Any ¶
func (c *RouterGroup) Any(relativePath string, handlers ...HandlerFunc)
Any is a shortcut for all request methods
func (*RouterGroup) DELETE ¶
func (c *RouterGroup) DELETE(relativePath string, handlers ...HandlerFunc)
DELETE is a shortcut for router.Handle("DELETE", path, handle)
func (*RouterGroup) GET ¶
func (c *RouterGroup) GET(relativePath string, handlers ...HandlerFunc)
GET is a shortcut for router.Handle("GET", path, handle)
func (*RouterGroup) Group ¶
func (c *RouterGroup) Group(relativePath string, fn func(*RouterGroup), handlers ...HandlerFunc) *RouterGroup
Creates a new router group. You should add all the routes that have common middlwares or the same path prefix. For example, all the routes that use a common middlware for authorization could be grouped.
func (*RouterGroup) HEAD ¶
func (c *RouterGroup) HEAD(relativePath string, handlers ...HandlerFunc)
HEAD is a shortcut for router.Handle("HEAD", path, handle)
func (*RouterGroup) Handle ¶
func (c *RouterGroup) Handle(httpMethod, relativePath string, handlers []HandlerFunc)
Handle registers a new request handle and middlewares with the given path and method. The last handler should be the real handler, the other ones should be middlewares that can and should be shared among different routes.
For GET, POST, PUT, PATCH and DELETE requests the respective shortcut functions can be used.
This function is intended for bulk loading and to allow the usage of less frequently used, non-standardized or custom methods (e.g. for internal communication with a proxy).
func (*RouterGroup) OPTIONS ¶
func (c *RouterGroup) OPTIONS(relativePath string, handlers ...HandlerFunc)
OPTIONS is a shortcut for router.Handle("OPTIONS", path, handle)
func (*RouterGroup) PATCH ¶
func (c *RouterGroup) PATCH(relativePath string, handlers ...HandlerFunc)
PATCH is a shortcut for router.Handle("PATCH", path, handle)
func (*RouterGroup) POST ¶
func (c *RouterGroup) POST(relativePath string, handlers ...HandlerFunc)
POST is a shortcut for router.Handle("POST", path, handle)
func (*RouterGroup) PUT ¶
func (c *RouterGroup) PUT(relativePath string, handlers ...HandlerFunc)
PUT is a shortcut for router.Handle("PUT", path, handle)
func (*RouterGroup) Static ¶
func (c *RouterGroup) Static(path, dir string)
Static serves files from the given file system root. Internally a http.FileServer is used, therefore http.NotFound is used instead of the Router's NotFound handler. To use the operating system's file system implementation, use : router.Static("/static", "/var/www")
func (*RouterGroup) Use ¶
func (c *RouterGroup) Use(middlewares ...HandlerFunc)
Adds middlewares to the group
type Session ¶
type Session interface { Get(key interface{}) interface{} Set(key interface{}, val interface{}) Delete(key interface{}) Clear() AddFlash(value interface{}, vars ...string) Flashes(vars ...string) []interface{} Options(SessionOptions) }
Session stores the values and optional configuration for a session.
type SessionOptions ¶
SessionOptions stores configuration for a session or session store.
type SessionStore ¶
type SessionStore interface { sessions.Store Options(SessionOptions) }
SessionStore is an interface for custom session stores.