Documentation ¶
Overview ¶
Mirango is a conveniently smart web framework that is built with reusibility and easiness in mind.
Mirango supports the following handler types:
mirango.Handler mirango.HandlerFunc func(*Context) interface{} func(*Context) framework.Handler framework.HandlerFunc func(framework.Context) interface{} func(framework.Context) func(*Response, *Request) interface{} func(*Response, *Request) func(framework.Response, framework.Request) interface{} func(framework.Response, framework.Request) http.Handler http.HandlerFunc func(http.ResponseWriter, *http.Request) interface{} func(http.ResponseWriter, *http.Request)
Index ¶
- Constants
- func With(mw ...interface{}) middleware
- func WriteAsJson(w http.ResponseWriter, status int, value interface{}) (int, error)
- func WriteAsXml(w http.ResponseWriter, status int, value interface{}, writeHeader bool) (int, error)
- func WriteEntity(w http.ResponseWriter, status int, value interface{}, encoding string) (int, error)
- func WriteJson(w http.ResponseWriter, status int, value interface{}, contentType string) (int, error)
- func WriteString(w http.ResponseWriter, status int, str string) (int, error)
- type CaseSensitive
- type Context
- func (c *Context) End()
- func (c *Context) GetValue(k interface{}) framework.Value
- func (c *Context) Header() http.Header
- func (c *Context) ID() int64
- func (c *Context) Locale() framework.Locale
- func (c *Context) Operation() framework.Operation
- func (c *Context) SetValue(k interface{}, v interface{})
- func (c *Context) User() framework.User
- func (c *Context) Value(k interface{}) interface{}
- func (c *Context) Values() framework.Values
- type Handler
- type HandlerFunc
- type Middleware
- type Mirango
- func (m *Mirango) Codecs(c ...framework.Codec)
- func (m *Mirango) Decoders(d ...framework.Decoder)
- func (m *Mirango) Encoders(e ...framework.Encoder)
- func (m *Mirango) Logger(l framework.Logger)
- func (m *Mirango) Params(params ...*Param) *Mirango
- func (m *Mirango) Prepare()
- func (m *Mirango) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (m *Mirango) Server(s framework.Server)
- func (m *Mirango) SessionStore(ss framework.SessionStore)
- func (m *Mirango) Start(addr string) error
- func (m *Mirango) StartTLS(addr string, certFile string, keyFile string) error
- func (n Mirango) String() string
- type Operation
- func DELETE(h interface{}) *Operation
- func DELETENested(h interface{}, cb func(*Operation)) *Operation
- func GET(h interface{}) *Operation
- func GETNested(h interface{}, cb func(*Operation)) *Operation
- func NewOperation(h interface{}) *Operation
- func PATCH(h interface{}) *Operation
- func PATCHNested(h interface{}, cb func(*Operation)) *Operation
- func POST(h interface{}) *Operation
- func POSTNested(h interface{}, cb func(*Operation)) *Operation
- func PUT(h interface{}) *Operation
- func PUTNested(h interface{}, cb func(*Operation)) *Operation
- func (o *Operation) Accepts(accepts ...string) *Operation
- func (o *Operation) AcceptsOnly(accepts ...string) *Operation
- func (o *Operation) Apply(p ...Preset) *Operation
- func (o *Operation) BodyParam(name string) *Param
- func (o *Operation) BuildPath(v ...interface{}) string
- func (o *Operation) Clone() *Operation
- func (o *Operation) GetAccepts() []string
- func (o *Operation) GetFullPath() string
- func (o *Operation) GetMethods() []string
- func (o *Operation) GetMiddleware() []Middleware
- func (o *Operation) GetName() string
- func (o *Operation) GetParams() *Params
- func (o *Operation) GetPath() string
- func (o *Operation) GetReturns() []string
- func (o *Operation) GetRoute() framework.Route
- func (o *Operation) GetSchemes() []string
- func (o *Operation) HeaderParam(name string) *Param
- func (o *Operation) Methods(methods ...string) *Operation
- func (o *Operation) Name(name string) *Operation
- func (o *Operation) Params(params ...*Param) *Operation
- func (o *Operation) PathParam(name string) *Param
- func (o *Operation) QueryParam(name string) *Param
- func (o *Operation) Returns(returns ...string) *Operation
- func (o *Operation) ReturnsOnly(returns ...string) *Operation
- func (o *Operation) Schemes(schemes ...string) *Operation
- func (o *Operation) SchemesOnly(schemes ...string) *Operation
- func (o *Operation) ServeHTTP(c *Context) interface{}
- func (o *Operation) Uses(h interface{}) *Operation
- func (o *Operation) With(mw ...interface{}) *Operation
- type Operations
- func (ops *Operations) Append(operations ...*Operation)
- func (ops *Operations) Apply(p ...Preset)
- func (ops *Operations) Clone() *Operations
- func (ops *Operations) Get(name string) *Operation
- func (ops *Operations) GetAll() []*Operation
- func (ops *Operations) GetByIndex(i int) *Operation
- func (ops *Operations) GetByMethod(method string) *Operation
- func (ops *Operations) Len() int
- func (ops *Operations) Set(operations ...*Operation)
- func (ops *Operations) Union(nops *Operations)
- type Param
- func (p *Param) As(as framework.ValueType) *Param
- func (p *Param) Clone() *Param
- func (p *Param) File() *Param
- func (p *Param) GetAs() framework.ValueType
- func (p *Param) GetName() string
- func (p *Param) In(in ...paramIn) *Param
- func (p *Param) IsFile() bool
- func (p *Param) IsIn(in ...paramIn) bool
- func (p *Param) IsMultiple() bool
- func (p *Param) IsRequired() bool
- func (p *Param) Multiple() *Param
- func (p *Param) Name(name string) *Param
- func (p *Param) Required() *Param
- func (p *Param) Validate(c framework.Context, v framework.ParamValue) *validation.Error
- func (p *Param) ValidateAll(c framework.Context, v framework.ParamValue) *validation.Error
- func (p *Param) Validators(validators ...validation.Validator) *Param
- type Params
- func (p *Params) Append(params ...*Param)
- func (p *Params) Clone() *Params
- func (p *Params) ContainsBodyParams() bool
- func (p *Params) ContainsFiles() bool
- func (p *Params) Get(name string) *Param
- func (p *Params) GetAll() map[string]*Param
- func (p *Params) Len() int
- func (p *Params) Set(params ...*Param)
- func (p *Params) Union(params *Params)
- func (pa *Params) Validate(c framework.Context, vs framework.ParamValues) *validation.Error
- func (pa *Params) ValidateAll(c framework.Context, vs framework.ParamValues) *validation.Error
- func (pa *Params) ValidateFirst(c framework.Context, vs framework.ParamValues) *validation.Error
- type Preset
- type PresetFunc
- type Presets
- type Request
- func (r *Request) GetSessionValue(string, interface{}) (framework.Value, error)
- func (r *Request) IsSet(name string) bool
- func (r *Request) Method() string
- func (r *Request) Param(name string) framework.ParamValue
- func (r *Request) Params(names ...string) framework.ParamValues
- func (r *Request) Path() string
- func (r *Request) Session(name string) framework.Session
- func (r *Request) Sessions() framework.Sessions
- func (r *Request) SetSessionValue(string, interface{}, interface{}) error
- type Resource
- func (r *Resource) AddResource(resource *Resource) *Resource
- func (r *Resource) AddResourceNested(resource *Resource, cb func(*Resource)) *Resource
- func (r *Resource) Clone() *Resource
- func (r *Resource) Resource(name string, re interface{}) *Resource
- func (r *Resource) ResourceNested(name string, re interface{}, cb func(*Resource)) *Resource
- type Response
- func (w *Response) CloseNotify() <-chan bool
- func (w *Response) ContentLength() int
- func (w *Response) Flush()
- func (w *Response) Render(c *Context, data interface{}) error
- func (w *Response) StatusCode() int
- func (w *Response) Stream(status int, d time.Duration, f func(int64) (interface{}, bool)) error
- func (w *Response) StreamAsJson(status int, d time.Duration, f func(int64) (interface{}, bool)) error
- func (w *Response) StreamAsXml(status int, d time.Duration, f func(int64) (interface{}, bool)) error
- func (w *Response) Write(bytes []byte) (int, error)
- func (w *Response) WriteAsJson(status int, value interface{}) error
- func (w *Response) WriteAsXml(status int, value interface{}, writeHeader bool) error
- func (w *Response) WriteEntity(status int, value interface{}) error
- func (w *Response) WriteHeader(httpStatus int)
- func (w *Response) WriteJson(status int, value interface{}, contentType string) error
- func (w *Response) WriteString(status int, str string) error
- type Route
- func (r *Route) Accepts(accepts ...string) *Route
- func (r *Route) AcceptsOnly(accepts ...string) *Route
- func (r *Route) AddResource(resource *Resource) *Resource
- func (r *Route) AddResourceNested(resource *Resource, cb func(*Resource)) *Resource
- func (r *Route) AddRoute(route *Route) *Route
- func (r *Route) AddRouteNested(route *Route, cb func(*Route)) *Route
- func (r *Route) Apply(p ...Preset)
- func (r *Route) BodyParam(name string) *Param
- func (r *Route) Branch(path interface{}) *Route
- func (r *Route) BranchNested(path interface{}, cb func(*Route)) *Route
- func (r *Route) BuildPath(v ...interface{}) string
- func (r *Route) Clone() *Route
- func (r *Route) DELETE(h interface{}) *Operation
- func (r *Route) DELETENested(h interface{}, cb func(*Operation)) *Operation
- func (r *Route) GET(h interface{}) *Operation
- func (r *Route) GETNested(h interface{}, cb func(*Operation)) *Operation
- func (r *Route) GetAccepts() []string
- func (r *Route) GetFullPath() string
- func (r *Route) GetMethodNotAllowedHandler() Handler
- func (r *Route) GetMiddleware() []Middleware
- func (r *Route) GetNotFoundHandler() Handler
- func (r *Route) GetOperations() *Operations
- func (r *Route) GetPanicHandler() Handler
- func (r *Route) GetParams() *Params
- func (r *Route) GetPath() string
- func (r *Route) GetReturns() []string
- func (r *Route) GetSchemes() []string
- func (r *Route) HeaderParam(name string) *Param
- func (r *Route) MethodNotAllowedHandler(h interface{}) *Route
- func (r *Route) NotFoundHandler(h interface{}) *Route
- func (r *Route) Operations(ops ...*Operation) *Route
- func (r *Route) PATCH(h interface{}) *Operation
- func (r *Route) PATCHNested(h interface{}, cb func(*Operation)) *Operation
- func (r *Route) POST(h interface{}) *Operation
- func (r *Route) POSTNested(h interface{}, cb func(*Operation)) *Operation
- func (r *Route) PUT(h interface{}) *Operation
- func (r *Route) PUTNested(h interface{}, cb func(*Operation)) *Operation
- func (r *Route) PanicHandler(h interface{}) *Route
- func (r *Route) Params(params ...*Param) *Route
- func (r *Route) PathParam(name string) *Param
- func (r *Route) QueryParam(name string) *Param
- func (r *Route) Resource(name string, re interface{}) *Resource
- func (r *Route) ResourceNested(name string, re interface{}, cb func(*Resource)) *Resource
- func (r *Route) Returns(returns ...string) *Route
- func (r *Route) ReturnsOnly(returns ...string) *Route
- func (r *Route) Schemes(schemes ...string) *Route
- func (r *Route) SchemesOnly(schemes ...string) *Route
- func (r *Route) ServeHTTP(c *Context, res result) interface{}
- func (r *Route) With(mw ...interface{}) *Route
- type Server
Constants ¶
View Source
const ( IN_PATH paramIn = iota IN_QUERY IN_HEADER IN_BODY )
Variables ¶
This section is empty.
Functions ¶
func WriteAsJson ¶
func WriteAsJson(w http.ResponseWriter, status int, value interface{}) (int, error)
func WriteAsXml ¶
func WriteEntity ¶
func WriteString ¶
Types ¶
type CaseSensitive ¶
type CaseSensitive string
type Context ¶
type Context struct { framework.LogWriter *Response *Request // contains filtered or unexported fields }
func NewContext ¶
type HandlerFunc ¶
type HandlerFunc func(*Context) interface{}
func (HandlerFunc) ServeHTTP ¶
func (f HandlerFunc) ServeHTTP(c *Context) interface{}
type Middleware ¶
func CheckAccepts ¶
func CheckAccepts(o *Operation) Middleware
func CheckParams ¶
func CheckParams(o *Operation) Middleware
func CheckReturns ¶
func CheckReturns(o *Operation) Middleware
func CheckSchemes ¶
func CheckSchemes(o *Operation) Middleware
func MiddlewareFunc ¶
func MiddlewareFunc(f func(Handler) Handler) Middleware
type Mirango ¶
type Mirango struct { *Route // contains filtered or unexported fields }
func (*Mirango) SessionStore ¶
func (m *Mirango) SessionStore(ss framework.SessionStore)
type Operation ¶
type Operation struct {
// contains filtered or unexported fields
}
func DELETENested ¶
func NewOperation ¶
func NewOperation(h interface{}) *Operation
func PATCHNested ¶
func POSTNested ¶
func (*Operation) AcceptsOnly ¶
func (*Operation) GetAccepts ¶
func (*Operation) GetFullPath ¶
func (*Operation) GetMethods ¶
func (*Operation) GetMiddleware ¶
func (o *Operation) GetMiddleware() []Middleware
func (*Operation) GetReturns ¶
func (*Operation) GetSchemes ¶
func (*Operation) HeaderParam ¶
func (*Operation) QueryParam ¶
func (*Operation) ReturnsOnly ¶
func (*Operation) SchemesOnly ¶
type Operations ¶
type Operations struct {
// contains filtered or unexported fields
}
func NewOperations ¶
func NewOperations() *Operations
func (*Operations) Append ¶
func (ops *Operations) Append(operations ...*Operation)
func (*Operations) Apply ¶
func (ops *Operations) Apply(p ...Preset)
func (*Operations) Clone ¶
func (ops *Operations) Clone() *Operations
func (*Operations) Get ¶
func (ops *Operations) Get(name string) *Operation
func (*Operations) GetAll ¶
func (ops *Operations) GetAll() []*Operation
func (*Operations) GetByIndex ¶
func (ops *Operations) GetByIndex(i int) *Operation
func (*Operations) GetByMethod ¶
func (ops *Operations) GetByMethod(method string) *Operation
func (*Operations) Len ¶
func (ops *Operations) Len() int
func (*Operations) Set ¶
func (ops *Operations) Set(operations ...*Operation)
func (*Operations) Union ¶
func (ops *Operations) Union(nops *Operations)
type Param ¶
type Param struct {
// contains filtered or unexported fields
}
Param
func HeaderParam ¶
func QueryParam ¶
func (*Param) IsMultiple ¶
func (*Param) IsRequired ¶
func (*Param) Validate ¶
func (p *Param) Validate(c framework.Context, v framework.ParamValue) *validation.Error
Validate returns the first error it encountered
func (*Param) ValidateAll ¶
func (p *Param) ValidateAll(c framework.Context, v framework.ParamValue) *validation.Error
ValidateAll returns all the errors it encountered
func (*Param) Validators ¶
func (p *Param) Validators(validators ...validation.Validator) *Param
Must sets the validators to use.
type Params ¶
type Params struct {
// contains filtered or unexported fields
}
func (*Params) ContainsBodyParams ¶
func (*Params) ContainsFiles ¶
func (*Params) Validate ¶
func (pa *Params) Validate(c framework.Context, vs framework.ParamValues) *validation.Error
Validate returns the first error it encountered
func (*Params) ValidateAll ¶
func (pa *Params) ValidateAll(c framework.Context, vs framework.ParamValues) *validation.Error
ValidateAll returns all the errors it encountered for each param
func (*Params) ValidateFirst ¶
func (pa *Params) ValidateFirst(c framework.Context, vs framework.ParamValues) *validation.Error
ValidateFirst returns the first error it encountered for each param
type PresetFunc ¶
type PresetFunc func(*Operation)
func (PresetFunc) ApplyTo ¶
func (f PresetFunc) ApplyTo(o *Operation)
type Request ¶
func NewRequest ¶
func (*Request) GetSessionValue ¶
func (*Request) Param ¶
func (r *Request) Param(name string) framework.ParamValue
Param returns the input parameter value by its name.
func (*Request) SetSessionValue ¶
type Resource ¶
type Resource struct { Name string Route *Route EntityRoute *Route Index *Operation Create *Operation Get *Operation Update *Operation Patch *Operation Delete *Operation // contains filtered or unexported fields }
func NewResource ¶
func NewResourceNested ¶
func (*Resource) AddResource ¶
func (*Resource) AddResourceNested ¶
type Response ¶
type Response struct { http.ResponseWriter // contains filtered or unexported fields }
func NewResponse ¶
func NewResponse(w http.ResponseWriter, encoders framework.Encoders) *Response
func (*Response) CloseNotify ¶
func (*Response) ContentLength ¶
func (*Response) StatusCode ¶
func (*Response) StreamAsJson ¶
func (*Response) StreamAsXml ¶
func (*Response) WriteAsJson ¶
func (*Response) WriteAsXml ¶
func (*Response) WriteEntity ¶
func (*Response) WriteHeader ¶
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
func NewRouteNested ¶
func (*Route) AcceptsOnly ¶
func (*Route) AddResource ¶
func (*Route) AddResourceNested ¶
func (*Route) BranchNested ¶
func (*Route) DELETENested ¶
func (*Route) GetAccepts ¶
func (*Route) GetFullPath ¶
func (*Route) GetMethodNotAllowedHandler ¶
func (*Route) GetMiddleware ¶
func (r *Route) GetMiddleware() []Middleware
func (*Route) GetNotFoundHandler ¶
func (*Route) GetOperations ¶
func (r *Route) GetOperations() *Operations
func (*Route) GetPanicHandler ¶
func (*Route) GetReturns ¶
func (*Route) GetSchemes ¶
func (*Route) HeaderParam ¶
func (*Route) MethodNotAllowedHandler ¶
func (*Route) NotFoundHandler ¶
func (*Route) Operations ¶
func (*Route) PATCHNested ¶
func (*Route) POSTNested ¶
func (*Route) PanicHandler ¶
func (*Route) QueryParam ¶
func (*Route) ResourceNested ¶
func (*Route) ReturnsOnly ¶
func (*Route) SchemesOnly ¶
type Server ¶
func DefaultServer ¶
func DefaultServer() *Server
func (*Server) ListenAndServe ¶
func (*Server) ListenAndServeTLS ¶
func (*Server) SetHandler ¶
Click to show internal directories.
Click to hide internal directories.