Documentation
¶
Index ¶
- Constants
- func AuthError(format string, a ...interface{}) *response.Response
- func Delete(route string, do interface{}) *handler
- func Get(route string, do interface{}) *handler
- func Patch(route string, do interface{}) *handler
- func Post(route string, do interface{}) *handler
- func Put(route string, do interface{}) *handler
- func ValidateError(format string, a ...interface{}) *response.Response
- type DefaultFairing
- type Fairing
- type Guard
- type Rocket
- func (rk *Rocket) Attach(f Fairing) *Rocket
- func (rk *Rocket) Default(do interface{}) *Rocket
- func (rk *Rocket) EnableHTTPs(certFile, keyFile string) *Rocket
- func (rk *Rocket) Launch()
- func (rk *Rocket) Mount(handlers ...*handler) *Rocket
- func (rk *Rocket) OnClose(f func() error) *Rocket
- func (rk *Rocket) ServeHTTP(w http.ResponseWriter, r *http.Request)
Constants ¶
const ErrorMessageForMethodNotAllowed = "request resource does not support http method '%s'"
Variables ¶
This section is empty.
Functions ¶
func Delete ¶ added in v0.7.1
func Delete(route string, do interface{}) *handler
Delete return delete handler.
func Get ¶ added in v0.5.0
func Get(route string, do interface{}) *handler
Get return a get handler.
func Patch ¶ added in v0.12.0
func Patch(route string, do interface{}) *handler
Patch return a patch handler.
func Post ¶ added in v0.7.0
func Post(route string, do interface{}) *handler
Post return a post handler.
func Put ¶ added in v0.7.1
func Put(route string, do interface{}) *handler
Put return a put handler.
func ValidateError ¶ added in v0.13.0
Types ¶
type DefaultFairing ¶ added in v1.1.0
type DefaultFairing struct{}
DefaultFairing provides default implement for your fairing by embedded it into your fairing type, Embedded is a good practice because fairing is designed to allowed partial implement interface
func (DefaultFairing) OnLaunch ¶ added in v1.1.0
func (f DefaultFairing) OnLaunch(*Rocket)
func (DefaultFairing) OnRequest ¶ added in v1.1.0
func (f DefaultFairing) OnRequest(req *http.Request) *http.Request
func (DefaultFairing) OnResponse ¶ added in v1.1.0
func (f DefaultFairing) OnResponse(resp *response.Response) *response.Response
type Fairing ¶ added in v0.14.0
type Fairing interface {
OnRequest(*http.Request) *http.Request
OnResponse(*response.Response) *response.Response
// OnLaunch would let you could get the metadata of rocket server
//
// NOTE: only work when you using `Launch()` to start server
// won't work while you use rocket as HTTP handler
OnLaunch(*Rocket)
}
Fairing specify the method that fairing could implement
type Guard ¶ added in v0.13.0
Guard is an interface that context can implement, when context implement this, context can reject request with a *response.Response.
type Rocket ¶
type Rocket struct {
// MultiFormBodySizeLimit decide the multiple forms value size
MultiFormBodySizeLimit int64
// contains filtered or unexported fields
}
Rocket is our service.
func (*Rocket) Attach ¶ added in v0.12.7
Attach add fairing to lifecycle for each request and response
func (*Rocket) Default ¶ added in v0.12.0
Default receive a function that have signature `func() <T>` for custom response when no route matched, <T> means a legal response Type of rocket, e.g. `*response.Response`, `response.Json` by default that(status code 404) would returns `"page not found"` when no set this function,
func (*Rocket) EnableHTTPs ¶ added in v0.14.0
EnableHTTPs would get certFile and keyFile to enable HTTPs