Documentation
¶
Index ¶
- Variables
- type Cookie
- type Gor
- type HandlerFunc
- type HandlerFuncNext
- type Middleware
- type Next
- type Req
- type Res
- func (res *Res) AddHeader(key, val string)
- func (res *Res) End()
- func (res *Res) Error(v string)
- func (res *Res) HTML(v string, data interface{})
- func (res *Res) JSON(v interface{})
- func (res *Res) Redirect(path string)
- func (res *Res) Send(v interface{})
- func (res *Res) SendStatus(code int)
- func (res *Res) SetCookie(key, val string, option ...Cookie)
- func (res *Res) Status(code int) *Res
- func (res *Res) Write(data []byte) (int, error)
- type Route
- func (r *Route) All(hs ...interface{})
- func (r *Route) Connect(pattern string, h HandlerFunc)
- func (r *Route) Delete(pattern string, h HandlerFunc)
- func (r *Route) Get(pattern string, h HandlerFunc)
- func (r *Route) Group(pattern string, app func(group *Router))
- func (r *Route) Head(pattern string, h HandlerFunc)
- func (r *Route) Options(pattern string, h HandlerFunc)
- func (r *Route) Patch(pattern string, h HandlerFunc)
- func (r *Route) Post(pattern string, h HandlerFunc)
- func (r *Route) Put(pattern string, h HandlerFunc)
- func (r *Route) Trace(pattern string, h HandlerFunc)
- func (r *Route) Use(hs ...interface{})
- type RouteInterface
- type Router
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is not found error. ErrNotFound = errors.New("not found page") // ErrResponseTypeUnsupported is response type unsupported error. ErrResponseTypeUnsupported = errors.New("response type unsupported") // ErrJSONMarshal is json marshal error. ErrJSONMarshal = errors.New("json marshal err") // ErrHTTPStatusCodeInvalid is given http status code is invalid error. ErrHTTPStatusCodeInvalid = errors.New("http status code is invalid") )
Functions ¶
This section is empty.
Types ¶
type Cookie ¶
type Cookie struct {
Path string // optional
Domain string // optional
Expires time.Time // optional
RawExpires string // for reading cookies only
// MaxAge=0 means no 'Max-Age' attribute specified.
// MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'
// MaxAge>0 means Max-Age attribute present and given in seconds
MaxAge int
Secure bool
HTTPOnly bool
Raw string
Unparsed []string // Raw text of unparsed attribute-value pairs
}
Cookie like http.Cookie but remove name and value
type Gor ¶
type Gor struct {
*Route
// contains filtered or unexported fields
}
Gor gor framework core struct
func (*Gor) ServeHTTP ¶
func (g *Gor) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP use to start server
func (*Gor) SetStaticPath ¶
SetStaticPath set static url path start string
type HandlerFunc ¶
HandlerFunc gor handler func like http.HandlerFunc func(ResponseWriter, *Request)
type HandlerFuncNext ¶
HandlerFuncNext gor handler func like http.HandlerFunc func(ResponseWriter, *Request), but return HandlerFunc to do somrthing at defer time
type Middleware ¶
type Middleware interface {
// contains filtered or unexported methods
}
Middleware mid
type Req ¶
type Req struct {
Protocol string
Secure bool
Method string
Query map[string][]string
Headers map[string][]string
Hostname string
BaseURL string
OriginalURL string
Params map[string]string
Body *bodyData
// contains filtered or unexported fields
}
Req is http Request struct <scheme>://<username>:<password>@<host>:<port>/<path>;<parameters>?<query>#<fragment>
func (*Req) AddContext ¶
func (req *Req) AddContext(key, val interface{})
AddContext add value to gor context
func (*Req) GetContext ¶
func (req *Req) GetContext(key interface{}) interface{}
GetContext get context from gor by key
type Res ¶
type Res struct {
Response interface{}
StatusCode int
// contains filtered or unexported fields
}
Res is http ResponseWriter and some gor Response method
func (*Res) SendStatus ¶
SendStatus set Response http status code with its text
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
Route route
func (*Route) Connect ¶
func (r *Route) Connect(pattern string, h HandlerFunc)
Connect http connect method
func (*Route) Delete ¶
func (r *Route) Delete(pattern string, h HandlerFunc)
Delete http delete method
func (*Route) Options ¶
func (r *Route) Options(pattern string, h HandlerFunc)
Options http options method
type RouteInterface ¶
type RouteInterface interface {
Use(...interface{})
All(...interface{})
Group(string, func(group *Router))
Middleware
// contains filtered or unexported methods
}
RouteInterface define Route Interface
