mirror of
https://github.com/labstack/echo.git
synced 2025-01-12 01:22:21 +02:00
Wrote some godoc
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
1aad369f59
commit
60adfc8231
26
bolt.go
26
bolt.go
@ -16,6 +16,9 @@ type (
|
|||||||
internalServerErrorHandler HandlerFunc
|
internalServerErrorHandler HandlerFunc
|
||||||
pool sync.Pool
|
pool sync.Pool
|
||||||
}
|
}
|
||||||
|
// Option is used to configure bolt. They are passed while creating a new
|
||||||
|
// instance of bolt.
|
||||||
|
Option func(*Bolt)
|
||||||
HandlerFunc func(*Context)
|
HandlerFunc func(*Context)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -40,7 +43,8 @@ var MethodMap = map[string]uint8{
|
|||||||
"TRACE": 9,
|
"TRACE": 9,
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(opts ...func(*Bolt)) (b *Bolt) {
|
// New creates a bolt instance with options.
|
||||||
|
func New(opts ...Option) (b *Bolt) {
|
||||||
b = &Bolt{
|
b = &Bolt{
|
||||||
maxParam: 5,
|
maxParam: 5,
|
||||||
notFoundHandler: func(c *Context) {
|
notFoundHandler: func(c *Context) {
|
||||||
@ -76,30 +80,32 @@ func New(opts ...func(*Bolt)) (b *Bolt) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// MaxParam sets the max path param supported. Default is 5, good
|
// MaxParam returns an option to set the max path param allowed. Default is 5,
|
||||||
// enough for many user.
|
// good enough for many users.
|
||||||
func MaxParam(n uint8) func(*Bolt) {
|
func MaxParam(n uint8) Option {
|
||||||
return func(b *Bolt) {
|
return func(b *Bolt) {
|
||||||
b.maxParam = n
|
b.maxParam = n
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotFoundHandler sets a custom NotFound hanlder.
|
// NotFoundHandler returns an option to set a custom NotFound hanlder.
|
||||||
func NotFoundHandler(h HandlerFunc) func(*Bolt) {
|
func NotFoundHandler(h HandlerFunc) Option {
|
||||||
return func(b *Bolt) {
|
return func(b *Bolt) {
|
||||||
b.notFoundHandler = h
|
b.notFoundHandler = h
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MethodNotAllowedHandler sets a custom MethodNotAllowed handler.
|
// MethodNotAllowedHandler returns an option to set a custom MethodNotAllowed
|
||||||
func MethodNotAllowedHandler(h HandlerFunc) func(*Bolt) {
|
// handler.
|
||||||
|
func MethodNotAllowedHandler(h HandlerFunc) Option {
|
||||||
return func(b *Bolt) {
|
return func(b *Bolt) {
|
||||||
b.methodNotAllowedHandler = h
|
b.methodNotAllowedHandler = h
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// InternalServerErrorHandler sets a custom InternalServerError handler.
|
// InternalServerErrorHandler returns an option to set a custom
|
||||||
func InternalServerErrorHandler(h HandlerFunc) func(*Bolt) {
|
// InternalServerError handler.
|
||||||
|
func InternalServerErrorHandler(h HandlerFunc) Option {
|
||||||
return func(b *Bolt) {
|
return func(b *Bolt) {
|
||||||
b.internalServerErrorHandler = h
|
b.internalServerErrorHandler = h
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user