Documentation ¶
Index ¶
- func CheckAuth(payload *Payload, response *Response) (status int, err error)
- func LoggingMiddleware(next http.Handler, skipBody bool) http.Handler
- type Gateway
- func (g *Gateway) GET(handler Handler, preprocessors ...Processor)
- func (g *Gateway) Handle(method string, handler Handler, preprocessors ...Processor)
- func (g *Gateway) POST(handler Handler, preprocessors ...Processor)
- func (g *Gateway) PUT(handler Handler, preprocessors ...Processor)
- func (g *Gateway) ServeHTTP(w http.ResponseWriter, req *http.Request)
- type Handler
- type Payload
- type Processor
- type Response
- type Router
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Gateway ¶
Gateway is a man in the middle to inject dependency It currently bind to HTTP method, it disregard path.
func NewGateway ¶
func (*Gateway) Handle ¶
Handle registers a handler matched by a request's method and URL's path. Pattern is a regexp that defines a matched URL.
type Payload ¶
type Payload struct { // the raw http.Request of this payload // Think twice before accessing it Req *http.Request // URL parameters Params []string // Map of params such as Auth, TimeSteam, version Meta map[string]interface{} // Map of action payload Data map[string]interface{} TokenStore authtoken.Store AssetStore asset.Store HookRegistry *hook.Registry ProviderRegistry *provider.Registry AppName string UserInfoID string UserInfo *skydb.UserInfo DBConn skydb.Conn Database skydb.Database NotificationSender push.Sender }
Payload is for passing payload to the actual handler
func (*Payload) AccessToken ¶
AccessToken return the user input string TODO: accept all header, json payload, query string(in order)
func (*Payload) RouteAction ¶
RouteAction must exist for every request
type Response ¶
type Response struct { Meta map[string]interface{} `json:"-"` Info interface{} `json:"info,omitempty"` Result interface{} `json:"result,omitempty"` Err skyerr.Error `json:"error,omitempty"` RequestID string `json:"request_id,omitempty"` DatabaseID string `json:"database_id,omitempty"` // contains filtered or unexported fields }
Response is interface for handler to write response to router
func (*Response) Header ¶
Header returns the header map being written before return a response. Mutating the map after calling WriteEntity has no effects.
func (*Response) WriteEntity ¶
WriteEntity writes a value as response to a request. Currently it only writes JSON response.