olive-go: github.com/alash3al/olive-go Index | Files

package olive

import "github.com/alash3al/olive-go"

Olive Version 3.0

Index

Package Files

olive.go

func Handler Uses

func Handler(h http.Handler, rtrn bool) handler

Convert any http.Handler compatible handler to an internal handler, and rtrn is what will be returned for "[don't]run the next matched route with the same method and patttern"

type App Uses

type App struct {
    // contains filtered or unexported fields
}

Our main structure

func New Uses

func New() *App

Create a new instance

func (*App) ANY Uses

func (self *App) ANY(path string, cb handler) *App

Handle ANY request method for the specified path with the specified callback; NOTE: this is based on "func(self *App) METHOD()"

func (*App) CONNECT Uses

func (self *App) CONNECT(path string, cb handler) *App

Handle CONNECT request for the specified path with the specified callback; NOTE: this is based on "func(self *App) METHOD()"

func (*App) DELETE Uses

func (self *App) DELETE(path string, cb handler) *App

Handle DELETE request for the specified path with the specified callback; NOTE: this is based on "func(self *App) METHOD()"

func (*App) GET Uses

func (self *App) GET(path string, cb handler) *App

Handle GET request for the specified path with the specified callback; NOTE: this is based on "func(self *App) METHOD()"

func (*App) GroupBy Uses

func (self *App) GroupBy(by, pattern string, fn grouper) *App

Group multiple routes by the specified section and its pattern with its grouper, olive currently supports by "host" or "path" only .

func (*App) HEAD Uses

func (self *App) HEAD(path string, cb handler) *App

Handle HEAD request for the specified path with the specified callback; NOTE: this is based on "func(self *App) METHOD()"

func (App) Listen Uses

func (self App) Listen(addr string) error

An Alias to http.ListenAndServe

func (App) ListenTLS Uses

func (self App) ListenTLS(addr string, certFile string, keyFile string) error

An Alias to http.ListenAndServeTLS

func (*App) METHOD Uses

func (self *App) METHOD(method, path string, cb handler) *App

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 Uses

func (self *App) OPTIONS(path string, cb handler) *App

Handle OPTIONS request for the specified path with the specified callback; NOTE: this is based on "func(self *App) METHOD()"

func (*App) PATCH Uses

func (self *App) PATCH(path string, cb handler) *App

Handle PATCH request for the specified path with the specified callback; NOTE: this is based on "func(self *App) METHOD()"

func (*App) POST Uses

func (self *App) POST(path string, cb handler) *App

Handle POST request for the specified path with the specified callback; NOTE: this is based on "func(self *App) METHOD()"

func (*App) PUT Uses

func (self *App) PUT(path string, cb handler) *App

Handle PUT request for the specified path with the specified callback; NOTE: this is based on "func(self *App) METHOD()"

func (App) ServeHTTP Uses

func (self App) ServeHTTP(res http.ResponseWriter, req *http.Request)

Dispatch all registered routes

func (*App) TRACE Uses

func (self *App) TRACE(path string, cb handler) *App

Handle TRACE request for the specified path with the specified callback; NOTE: this is based on "func(self *App) METHOD()"

type Context Uses

type Context struct {
    Req    *http.Request
    Res    http.ResponseWriter
    Params []string
    Vars   map[string]interface{}
}

A request context and properties

func (Context) AddHeader Uses

func (self Context) AddHeader(k, v string)

Add a header field

func (Context) DelHeader Uses

func (self Context) DelHeader(k string)

Delete the specified header field

func (Context) GetBody Uses

func (self Context) GetBody(v interface{}) (err error)

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) GetHeader Uses

func (self Context) GetHeader(k string) string

Get the specified header field "from the request"

func (Context) GetQuery Uses

func (self Context) GetQuery(body bool) url.Values

Return the url query vars, if body is true, then this function will parse the request body as x-www-form-urlencoded .

func (Context) LimitBody Uses

func (self Context) LimitBody(max int64)

Limit the size of the request body .

func (Context) SetBody Uses

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 .

func (Context) SetHeader Uses

func (self Context) SetHeader(k, v string)

Set a http header field

func (Context) SetStatus Uses

func (self Context) SetStatus(code int)

Set the status code

Package olive imports 8 packages (graph). Updated 2016-07-15. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).