Documentation ¶
Index ¶
- type Engine
- type HandlerFunc
- type HandlersChain
- type HookFunc
- type HookFuncWithErr
- type IRoute
- type IRouter
- type M
- type MethodForest
- type Option
- type Options
- type Param
- type Params
- type PianoKey
- func (pk *PianoKey) Break()
- func (pk *PianoKey) BreakWithMessage(code int, msg string)
- func (pk *PianoKey) BreakWithStatus(code int)
- func (pk *PianoKey) DefaultFormValue(key, defaultValue string) string
- func (pk *PianoKey) DefaultPostForm(key, defaultValue string) string
- func (pk *PianoKey) DefaultQuery(key, defaultValue string) string
- func (pk *PianoKey) FormValue(key string) string
- func (pk *PianoKey) Get(key string) (value any, ok bool)
- func (pk *PianoKey) JSON(code int, data any)
- func (pk *PianoKey) MustGet(key string) any
- func (pk *PianoKey) Next(ctx context.Context)
- func (pk *PianoKey) Param(key string) string
- func (pk *PianoKey) PostForm(key string) string
- func (pk *PianoKey) Query(key string) string
- func (pk *PianoKey) Set(key string, value any)
- func (pk *PianoKey) SetHandlers(handlers HandlersChain)
- func (pk *PianoKey) SetHeader(key, value string)
- func (pk *PianoKey) SetStatusCode(code int)
- func (pk *PianoKey) String(code int, format string, data ...any)
- type RouterGroup
- func (rg *RouterGroup) DELETE(relativePath string, handlers ...HandlerFunc)
- func (rg *RouterGroup) GET(relativePath string, handlers ...HandlerFunc)
- func (rg *RouterGroup) Group(relativePath string, handlers ...HandlerFunc) *RouterGroup
- func (rg *RouterGroup) HEAD(relativePath string, handlers ...HandlerFunc)
- func (rg *RouterGroup) Handle(httpMethod, relativePath string, handlers ...HandlerFunc)
- func (rg *RouterGroup) OPTIONS(relativePath string, handlers ...HandlerFunc)
- func (rg *RouterGroup) PATCH(relativePath string, handlers ...HandlerFunc)
- func (rg *RouterGroup) POST(relativePath string, handlers ...HandlerFunc)
- func (rg *RouterGroup) PUT(relativePath string, handlers ...HandlerFunc)
- func (rg *RouterGroup) Use(middleware ...HandlerFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct { RouterGroup // hook OnRun []HookFuncWithErr OnShutdown []HookFunc // contains filtered or unexported fields }
type HandlerFunc ¶
HandlerFunc is the core type of PIANO
type HookFuncWithErr ¶ added in v0.1.3
type IRoute ¶
type IRoute interface { Handle(string, string, ...HandlerFunc) GET(string, ...HandlerFunc) POST(string, ...HandlerFunc) PUT(string, ...HandlerFunc) DELETE(string, ...HandlerFunc) PATCH(string, ...HandlerFunc) OPTIONS(string, ...HandlerFunc) HEAD(string, ...HandlerFunc) }
type IRouter ¶
type IRouter interface { IRoute Group(string, ...HandlerFunc) *RouterGroup Use(...HandlerFunc) }
type Option ¶
type Option func(o *Options)
func WithHideBanner ¶ added in v0.1.5
func WithHideBanner() Option
func WithHostAddr ¶
WithHostAddr used to define addr you prefer
func WithShutdownTimeout ¶ added in v0.1.3
type Params ¶
type Params []Param
type PianoKey ¶
type PianoKey struct { Request *http.Request Writer http.ResponseWriter Params Params KVs M // contains filtered or unexported fields }
PianoKey play the piano with PianoKeys
func NewContext ¶
NewContext will return a new context object which is piano key
func (*PianoKey) BreakWithMessage ¶
func (*PianoKey) BreakWithStatus ¶
func (*PianoKey) DefaultFormValue ¶
func (*PianoKey) DefaultPostForm ¶
DefaultPostForm is PostForm with default value when no match
func (*PianoKey) DefaultQuery ¶
DefaultQuery is Query with default value when no match
func (*PianoKey) Get ¶
Get will return the value corresponding to the given key, it will return (nil, false) if key does not exist
func (*PianoKey) MustGet ¶
MustGet will return the value corresponding to the given key, it will panic if key does not exist
func (*PianoKey) SetHandlers ¶
func (pk *PianoKey) SetHandlers(handlers HandlersChain)
SetHandlers will set handlers field for PianoKey context
func (*PianoKey) SetStatusCode ¶
SetStatusCode is used to set HTTP response code
type RouterGroup ¶
type RouterGroup struct { Handlers HandlersChain // contains filtered or unexported fields }
func (*RouterGroup) DELETE ¶
func (rg *RouterGroup) DELETE(relativePath string, handlers ...HandlerFunc)
DELETE will handler HTTP DELETE request
func (*RouterGroup) GET ¶
func (rg *RouterGroup) GET(relativePath string, handlers ...HandlerFunc)
GET will handler HTTP GET request
func (*RouterGroup) Group ¶ added in v0.1.3
func (rg *RouterGroup) Group(relativePath string, handlers ...HandlerFunc) *RouterGroup
Group will new a route group
func (*RouterGroup) HEAD ¶ added in v0.1.3
func (rg *RouterGroup) HEAD(relativePath string, handlers ...HandlerFunc)
HEAD will handler HTTP HEAD request
func (*RouterGroup) Handle ¶ added in v0.1.3
func (rg *RouterGroup) Handle(httpMethod, relativePath string, handlers ...HandlerFunc)
Handle is suggested to use for custom methods
func (*RouterGroup) OPTIONS ¶ added in v0.1.3
func (rg *RouterGroup) OPTIONS(relativePath string, handlers ...HandlerFunc)
OPTIONS will handler HTTP OPTIONS request
func (*RouterGroup) PATCH ¶ added in v0.1.3
func (rg *RouterGroup) PATCH(relativePath string, handlers ...HandlerFunc)
PATCH will handler HTTP PATCH request
func (*RouterGroup) POST ¶
func (rg *RouterGroup) POST(relativePath string, handlers ...HandlerFunc)
POST will handler HTTP POST request
func (*RouterGroup) PUT ¶
func (rg *RouterGroup) PUT(relativePath string, handlers ...HandlerFunc)
PUT will handler HTTP PUT request
func (*RouterGroup) Use ¶ added in v0.1.3
func (rg *RouterGroup) Use(middleware ...HandlerFunc)
Use middlewares or other custom handlers