Documentation ¶
Overview ¶
Olive Version 3.0
Index ¶
- func Handler(h http.Handler, rtrn bool) handler
- type App
- func (self *App) ANY(path string, cb handler) *App
- func (self *App) CONNECT(path string, cb handler) *App
- func (self *App) DELETE(path string, cb handler) *App
- func (self *App) GET(path string, cb handler) *App
- func (self *App) GroupBy(by, pattern string, fn grouper) *App
- func (self *App) HEAD(path string, cb handler) *App
- func (self App) Listen(addr string) error
- func (self App) ListenTLS(addr string, certFile string, keyFile string) error
- func (self *App) METHOD(method, path string, cb handler) *App
- func (self *App) OPTIONS(path string, cb handler) *App
- func (self *App) PATCH(path string, cb handler) *App
- func (self *App) POST(path string, cb handler) *App
- func (self *App) PUT(path string, cb handler) *App
- func (self App) ServeHTTP(res http.ResponseWriter, req *http.Request)
- func (self *App) TRACE(path string, cb handler) *App
- type Context
- func (self Context) AddHeader(k, v string)
- func (self Context) DelHeader(k string)
- func (self Context) GetBody(v interface{}) (err error)
- func (self Context) GetHeader(k string) string
- func (self Context) GetQuery(body bool) url.Values
- func (self Context) LimitBody(max int64)
- func (self Context) SetBody(d ...interface{})
- func (self Context) SetHeader(k, v string)
- func (self Context) SetStatus(code int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
Our main structure
func (*App) ANY ¶
Handle ANY request method for the specified path with the specified callback; NOTE: this is based on "func(self *App) METHOD()"
func (*App) CONNECT ¶
Handle CONNECT request for the specified path with the specified callback; NOTE: this is based on "func(self *App) METHOD()"
func (*App) DELETE ¶
Handle DELETE request for the specified path with the specified callback; NOTE: this is based on "func(self *App) METHOD()"
func (*App) GET ¶
Handle GET request for the specified path with the specified callback; NOTE: this is based on "func(self *App) METHOD()"
func (*App) GroupBy ¶
Group multiple routes by the specified section and its pattern with its grouper, olive currently supports by "host" or "path" only .
func (*App) HEAD ¶
Handle HEAD request for the specified path with the specified callback; NOTE: this is based on "func(self *App) METHOD()"
func (*App) METHOD ¶
Handle the specified custom method for the specified path; NOTE: method could be a "regexp string"; NOTE: path could be a "regexp string";
func (*App) OPTIONS ¶
Handle OPTIONS request for the specified path with the specified callback; NOTE: this is based on "func(self *App) METHOD()"
func (*App) PATCH ¶
Handle PATCH request for the specified path with the specified callback; NOTE: this is based on "func(self *App) METHOD()"
func (*App) POST ¶
Handle POST request for the specified path with the specified callback; NOTE: this is based on "func(self *App) METHOD()"
func (*App) PUT ¶
Handle PUT request for the specified path with the specified callback; NOTE: this is based on "func(self *App) METHOD()"
type Context ¶
type Context struct { Req *http.Request Res http.ResponseWriter Params []string Vars map[string]interface{} }
A request context and properties
func (Context) GetBody ¶
Read the request body into the provided variable, it will read the body as json if the specified "v" isn't ([]byte, io.Writer) .
func (Context) GetQuery ¶
Return the url query vars, if body is true, then this function will parse the request body as x-www-form-urlencoded .
func (Context) SetBody ¶
func (self Context) SetBody(d ...interface{})
Write to the client, this function will detect the type of the data, it will send the data as json if the specified input isn't (string, []byte, *template.Template and io.Reader), it execute the input as html template if the first argument is *template.Template and second argument is template's data, you MUST LimitBody() to prevent memory-leaks attacks .