Documentation ¶
Index ¶
- Constants
- type App
- func (app *App) Delete(path string, ctx HandlerFunc, middlewares ...Middleware) *Route
- func (app *App) Get(path string, ctx HandlerFunc, middlewares ...Middleware) *Route
- func (app *App) GracefullyShutdown(server *http.Server)
- func (app *App) Group(prefix string, group GroupFunc, mds ...Middleware)
- func (app *App) Head(path string, ctx HandlerFunc, middlewares ...Middleware) *Route
- func (app *App) Middleware(middlewares ...Middleware)
- func (app *App) NotFound(ctx HandlerFunc)
- func (app *App) Options(path string, ctx HandlerFunc, middlewares ...Middleware) *Route
- func (app *App) Patch(path string, ctx HandlerFunc, middlewares ...Middleware) *Route
- func (app *App) Post(path string, ctx HandlerFunc, middlewares ...Middleware) *Route
- func (app *App) Put(path string, ctx HandlerFunc, middlewares ...Middleware) *Route
- func (app *App) RegisterRoutes() *httprouter.Router
- func (app *App) Run(args ...interface{}) *App
- func (app *App) ServeFiles(path string, root http.FileSystem)
- func (app *App) StartServer(server *http.Server)
- func (app *App) StartTLSServer(server *http.Server)
- func (app *App) Use(middlewares ...Middleware)
- type Context
- func (c *Context) Config() *config.Config
- func (c *Context) DecodeJSON(dst interface{}) error
- func (c *Context) Env() string
- func (c *Context) Err(err error)
- func (c *Context) Error(msg interface{})
- func (c *Context) File(name string)
- func (c *Context) GetData(key string) interface{}
- func (c *Context) HasData(key string) bool
- func (c *Context) HasQuery(key string) bool
- func (c *Context) JSON(data interface{}, code ...int)
- func (c *Context) Log() *log.Logger
- func (c *Context) Param(param string) string
- func (c *Context) ParseMultipartForm() error
- func (c *Context) Query(param string) string
- func (c *Context) Redirect(url string, code int)
- func (c *Context) Request() *http.Request
- func (c *Context) RequestID() string
- func (c *Context) Response() http.ResponseWriter
- func (c *Context) SetData(key string, data interface{})
- func (c *Context) SetRequest(r *http.Request)
- func (c *Context) SetRequestID(id string)
- func (c *Context) SetResponse(w http.ResponseWriter)
- func (c *Context) SetStatusCode(code int)
- func (c *Context) Status(code int)
- func (c *Context) StatusCode() int
- func (c *Context) View(temps string, data ...interface{}) error
- func (c *Context) ViewExists(tmp string) bool
- func (c *Context) ViewToString(temps string, data ...interface{}) (string, error)
- func (c *Context) WantsJSON() bool
- func (c *Context) Write(b []byte)
- func (c *Context) WriteHTML(html string)
- func (c *Context) WriteStatus(code int)
- func (c *Context) WriteString(s string)
- func (c *Context) WriteStringf(format string, a ...interface{})
- type ErrorFrame
- type ErrorJSON
- type Group
- func (g Group) Delete(path string, handler HandlerFunc, middlewares ...Middleware)
- func (g Group) Get(path string, handler HandlerFunc, middlewares ...Middleware)
- func (g Group) Group(prefix string, group GroupFunc, middlewares ...Middleware)
- func (g Group) Head(path string, handler HandlerFunc, middlewares ...Middleware)
- func (g Group) Options(path string, handler HandlerFunc, middlewares ...Middleware)
- func (g Group) Patch(path string, handler HandlerFunc, middlewares ...Middleware)
- func (g Group) Post(path string, handler HandlerFunc, middlewares ...Middleware)
- func (g Group) Put(path string, handler HandlerFunc, middlewares ...Middleware)
- func (g Group) ServeFiles(path string, root http.FileSystem)
- type GroupFunc
- type HandlerFunc
- type Log
- type Map
- type Middleware
- type RequestID
- type Route
Constants ¶
const ( KB = 1 << 10 MB = 1 << 20 GB = 1 << 30 )
some bytes :)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct { Routes []*Route Middlewares []Middleware Router *httprouter.Router Configs *config.Config Env string // Not found handler NotFoundHandler HandlerFunc // contains filtered or unexported fields }
App hold the framework options
func (*App) Delete ¶
func (app *App) Delete(path string, ctx HandlerFunc, middlewares ...Middleware) *Route
Delete Handle DELETE requests.
func (*App) Get ¶
func (app *App) Get(path string, ctx HandlerFunc, middlewares ...Middleware) *Route
Get Handle GET requests.
func (*App) GracefullyShutdown ¶
GracefullyShutdown the server
func (*App) Group ¶
func (app *App) Group(prefix string, group GroupFunc, mds ...Middleware)
Group adds a prefix to the given routes.
func (*App) Head ¶
func (app *App) Head(path string, ctx HandlerFunc, middlewares ...Middleware) *Route
Head Handle HEAD requests.
func (*App) Middleware ¶
func (app *App) Middleware(middlewares ...Middleware)
Middleware - add the middleware
func (*App) Options ¶
func (app *App) Options(path string, ctx HandlerFunc, middlewares ...Middleware) *Route
Options Handle OPTIONS requests.
func (*App) Patch ¶
func (app *App) Patch(path string, ctx HandlerFunc, middlewares ...Middleware) *Route
Patch Handle PATCH requests.
func (*App) Post ¶
func (app *App) Post(path string, ctx HandlerFunc, middlewares ...Middleware) *Route
Post Handle POST requests.
func (*App) Put ¶
func (app *App) Put(path string, ctx HandlerFunc, middlewares ...Middleware) *Route
Put Handle PUT requests.
func (*App) RegisterRoutes ¶
func (app *App) RegisterRoutes() *httprouter.Router
RegisterRoutes it's simply register the routes into the router.
func (*App) ServeFiles ¶
func (app *App) ServeFiles(path string, root http.FileSystem)
ServeFiles serve files in the given root.
func (*App) StartServer ¶
StartServer - Start kira server
func (*App) StartTLSServer ¶
StartTLSServer - start an TLS server provided by: Let's Encrypt. To generate keys:
- openssl genrsa -out server.key 2048
- openssl ecparam -genkey -name secp384r1 -out server.key
- openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650
func (*App) Use ¶
func (app *App) Use(middlewares ...Middleware)
Use is an alias of Middleware method.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context ...
func (*Context) DecodeJSON ¶
DecodeJSON - convert json from request body to interface.
func (*Context) Err ¶
Err checks if the error not empty. It's will redirect the error to Error method if there an error.
func (*Context) ParseMultipartForm ¶
ParseMultipartForm pars
func (*Context) Response ¶
func (c *Context) Response() http.ResponseWriter
Response is used by an HTTP handler to construct an HTTP response.
func (*Context) SetRequest ¶
SetRequest change the current request with the given one.
func (*Context) SetRequestID ¶
Code sets response status statusCode.
func (*Context) SetResponse ¶
func (c *Context) SetResponse(w http.ResponseWriter)
SetResponse change the current response with the given one.
func (*Context) SetStatusCode ¶
Code sets response status statusCode.
func (*Context) StatusCode ¶
Code gets response status statusCode.
func (*Context) ViewExists ¶
ViewExists Validate if the view exists.
func (*Context) ViewToString ¶
ViewToString parse a template and return the parsed template as a string.
func (*Context) WriteStatus ¶
WriteStatus Write HTTP header to the response and also write the status message to the body.
func (*Context) WriteString ¶
WriteString writes the content of s to the request response.
func (*Context) WriteStringf ¶
WriteStringf formats according to a format specifier and writes the resulting to the request response.
type ErrorFrame ¶
type ErrorFrame struct { File string `json:"file"` Func string `json:"func"` Line int `json:"line"` }
ErrorFrame ...
type ErrorJSON ¶
type ErrorJSON struct { Message string `json:"message"` Frames []ErrorFrame `json:"frames,omitempty"` }
ErrorJSON ...
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group represent routes group.
func (Group) Delete ¶
func (g Group) Delete(path string, handler HandlerFunc, middlewares ...Middleware)
Delete is a shortcut for app.Delete with the group prefix.
func (Group) Get ¶
func (g Group) Get(path string, handler HandlerFunc, middlewares ...Middleware)
Get is a shortcut for app.Get with the group prefix.
func (Group) Group ¶
func (g Group) Group(prefix string, group GroupFunc, middlewares ...Middleware)
Group adds ap refix to another grouped routes.
func (Group) Head ¶
func (g Group) Head(path string, handler HandlerFunc, middlewares ...Middleware)
Head is a shortcut for app.Head with the group prefix.
func (Group) Options ¶
func (g Group) Options(path string, handler HandlerFunc, middlewares ...Middleware)
Options is a shortcut for app.Delete with the group prefix.
func (Group) Patch ¶
func (g Group) Patch(path string, handler HandlerFunc, middlewares ...Middleware)
Patch is a shortcut for app.Patch with the group prefix.
func (Group) Post ¶
func (g Group) Post(path string, handler HandlerFunc, middlewares ...Middleware)
Post is a shortcut for app.Post with the group prefix.
func (Group) Put ¶
func (g Group) Put(path string, handler HandlerFunc, middlewares ...Middleware)
Put is a shortcut for app.Put with the group prefix.
func (Group) ServeFiles ¶
func (g Group) ServeFiles(path string, root http.FileSystem)
ServeFiles is a shortcut for app.ServeFiles with the group prefix.
type Log ¶
type Log struct{}
Log - log middleware
func (*Log) Middleware ¶
func (l *Log) Middleware(ctx *Context, next HandlerFunc)
Middleware handler.
type Map ¶
type Map map[string]interface{}
Map a type to represent map, this will be used alot in the internal statusCode.
type Middleware ¶
type Middleware interface { // Name() string Middleware(*Context, HandlerFunc) }
Middleware interface
type RequestID ¶
type RequestID struct{}
RequestID struct
func (*RequestID) Middleware ¶
func (rq *RequestID) Middleware(ctx *Context, next HandlerFunc)
Middleware handler.
type Route ¶
type Route struct { Method string Path string HandlerFunc HandlerFunc Middlewares []Middleware }
Route represent a route.
func (*Route) Middleware ¶
func (r *Route) Middleware(midd ...Middleware)
Middleware add a middleware to the route.
Source Files ¶
- context.go
- context_data.go
- context_json.go
- context_request.go
- context_response.go
- context_response_writer.go
- context_view.go
- kira.go
- kira_config.go
- kira_log.go
- kira_middleware.go
- kira_middleware_logger.go
- kira_middleware_request_id.go
- kira_recover.go
- kira_router.go
- kira_router_group.go
- kira_server.go
- kira_view.go
Directories ¶
Path | Synopsis |
---|---|
modules
|
|
log
Package log implements a simple logging package.
|
Package log implements a simple logging package. |
middlewares/csrf
We will re-write this based on this resource: https://astaxie.gitbooks.io/build-web-application-with-golang/content/en/09.1.html
|
We will re-write this based on this resource: https://astaxie.gitbooks.io/build-web-application-with-golang/content/en/09.1.html |