Documentation ¶
Index ¶
- type API
- func (api *API) AddMapMethod(key string, methods []string)
- func (api API) GetHeaderValueBool(key string, r *http.Request) (bool, error)
- func (api API) GetHeaderValueFloat64(key string, r *http.Request) (float64, error)
- func (api API) GetHeaderValueInt(key string, r *http.Request) (int, error)
- func (api API) GetHeaderValueInt64(key string, r *http.Request) (int64, error)
- func (api API) GetHeaderValueString(key string, r *http.Request) (string, error)
- func (api API) GetQueryParamValueBool(queryParamName string, r *http.Request) (bool, error)
- func (api API) GetQueryParamValueFloat64(queryParamName string, r *http.Request) (float64, error)
- func (api API) GetQueryParamValueInt(queryParamName string, r *http.Request) (int, error)
- func (api API) GetQueryParamValueInt64(queryParamName string, r *http.Request) (int64, error)
- func (api API) GetQueryParamValueString(queryParamName string, r *http.Request) (string, error)
- func (api API) GetRouteVarValueBool(urlVarName string, r *http.Request) (bool, error)
- func (api API) GetRouteVarValueFloat64(urlVarName string, r *http.Request) (float64, error)
- func (api API) GetRouteVarValueInt(urlVarName string, r *http.Request) (int, error)
- func (api API) GetRouteVarValueInt64(urlVarName string, r *http.Request) (int64, error)
- func (api API) GetRouteVarValueString(urlVarName string, r *http.Request) (string, error)
- func (api *API) RegisterNewAPIRequestValidator(v APIRequestValidater)
- func (api *API) RegisterNewAPIResponder(r APIResponder)
- func (api *API) RegisterNewAPIResponseFormatter(f APIResponseFormatter)
- func (api *API) RegisterNewAPISecurity(s APISecurity)
- func (api *API) Respond(data ResponseData, w http.ResponseWriter)
- func (api API) UnmarshalBody(v interface{}, r *http.Request) error
- func (api *API) ValidateBasicToken(token string) (client, secret string, valid bool)
- func (api *API) ValidateCustomToken(token string, customValidator CustomTokenValidator) (json.RawMessage, bool)
- func (api *API) ValidateMethods(keyMapMethod, method string) bool
- func (api *API) ValidateRequest(r *http.Request) (*RequestData, error)
- func (api API) Vars(r *http.Request) map[string]string
- type APIRequestValidater
- type APIResponder
- type APIResponseFormatter
- type APISecurity
- type CustomTokenValidator
- type MapMethods
- type Middleware
- type RequestData
- type ResponseData
- type ResponseFormatted
- type ResponseType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct { MapMethods *MapMethods // contains filtered or unexported fields }
API doc ...
func New ¶
func New(v APIRequestValidater, f APIResponseFormatter, r APIResponder, s APISecurity, mapMethods *MapMethods) *API
New doc ...
func (*API) AddMapMethod ¶
AddMapMethod doc ...
func (API) GetHeaderValueBool ¶
GetHeaderValueBool doc ...
func (API) GetHeaderValueFloat64 ¶
GetHeaderValueFloat64 doc ...
func (API) GetHeaderValueInt ¶
GetHeaderValueInt doc ...
func (API) GetHeaderValueInt64 ¶
GetHeaderValueInt64 doc ...
func (API) GetHeaderValueString ¶
GetHeaderValueString doc ...
func (API) GetQueryParamValueBool ¶
GetQueryParamValueBool ...
func (API) GetQueryParamValueFloat64 ¶
GetQueryParamValueFloat64 ...
func (API) GetQueryParamValueInt ¶
GetQueryParamValueInt ...
func (API) GetQueryParamValueInt64 ¶
GetQueryParamValueInt64 ...
func (API) GetQueryParamValueString ¶
GetQueryParamValueString ...
func (API) GetRouteVarValueBool ¶
GetRouteVarValueBool ...
func (API) GetRouteVarValueFloat64 ¶
GetRouteVarValueFloat64 ...
func (API) GetRouteVarValueInt ¶
GetRouteVarValueInt ...
func (API) GetRouteVarValueInt64 ¶
GetRouteVarValueInt64 ...
func (API) GetRouteVarValueString ¶
GetRouteVarValueString ...
func (*API) RegisterNewAPIRequestValidator ¶
func (api *API) RegisterNewAPIRequestValidator(v APIRequestValidater)
RegisterNewAPIRequestValidator doc ...
func (*API) RegisterNewAPIResponder ¶
func (api *API) RegisterNewAPIResponder(r APIResponder)
RegisterNewAPIResponder doc ...
func (*API) RegisterNewAPIResponseFormatter ¶
func (api *API) RegisterNewAPIResponseFormatter(f APIResponseFormatter)
RegisterNewAPIResponseFormatter doc ...
func (*API) RegisterNewAPISecurity ¶
func (api *API) RegisterNewAPISecurity(s APISecurity)
RegisterNewAPISecurity doc ...
func (*API) Respond ¶
func (api *API) Respond(data ResponseData, w http.ResponseWriter)
Respond doc ...
func (API) UnmarshalBody ¶
UnmarshalBody doc ...
func (*API) ValidateBasicToken ¶
ValidateBasicToken doc ...
func (*API) ValidateCustomToken ¶
func (api *API) ValidateCustomToken(token string, customValidator CustomTokenValidator) (json.RawMessage, bool)
ValidateCustomToken doc ...
func (*API) ValidateMethods ¶
ValidateMethods doc ...
func (*API) ValidateRequest ¶
func (api *API) ValidateRequest(r *http.Request) (*RequestData, error)
ValidateRequest doc ...
type APIRequestValidater ¶
type APIRequestValidater interface {
ValidateRequest(*http.Request) (*RequestData, error)
}
APIRequestValidater doc ...
type APIResponder ¶
type APIResponder interface {
Respond(*ResponseFormatted, http.ResponseWriter)
}
APIResponder doc ...
type APIResponseFormatter ¶
type APIResponseFormatter interface {
Format(ResponseData) *ResponseFormatted
}
APIResponseFormatter doc ...
type APISecurity ¶
type APISecurity interface { ValidateBasicToken(token string) (client, secret string, valid bool) ValidateCustomToken(token string, validator CustomTokenValidator) (json.RawMessage, bool) }
APISecurity doc ...
type CustomTokenValidator ¶
type CustomTokenValidator func(string) (json.RawMessage, bool)
CustomTokenValidator validator custom token func
type Middleware ¶
type Middleware func(next http.HandlerFunc) http.HandlerFunc
Middleware provides a convenient mechanism for filtering HTTP requests entering the application. It returns a new handler which may perform various operations and should finish by calling the next HTTP handler.
func MiddlewaresChain ¶
func MiddlewaresChain(mw ...Middleware) Middleware
MiddlewaresChain provides syntactic sugar to create a new middleware which will be the result of chaining the ones received as parameters.
type RequestData ¶
type RequestData struct { DeviceUUID string DeviceType string DeviceOS string OSVersion string OSTimezone string AppLanguage string AppVersion string AppName string SessionID string Headers map[string]string AdditionalInfo map[string]string RawBody []byte Data interface{} }
RequestData doc ..
func (*RequestData) AddAdditionalInfo ¶
func (data *RequestData) AddAdditionalInfo(key, value string)
AddAdditionalInfo func ...
type ResponseData ¶
type ResponseData struct { Title string Message string StatusCode int ErrorCode string Action string SessionID string ResponseType ResponseType Headers map[string]string AdditionalInfo map[string]string Data interface{} }
ResponseData doc ..
func (*ResponseData) AddAdditionalInfo ¶
func (data *ResponseData) AddAdditionalInfo(key, value string)
AddAdditionalInfo func ...
func (*ResponseData) AddHeader ¶
func (data *ResponseData) AddHeader(key, value string)
AddHeader doc
type ResponseFormatted ¶
ResponseFormatted ...