Documentation ¶
Index ¶
- Constants
- func AuthorizationFailed() (int, interface{}, http.Header)
- func Logger(request *http.Request, inner HandlerFunc) (int, interface{}, http.Header)
- func MethodNotAllowed(httpRequest *http.Request) (int, interface{}, http.Header)
- func PageNotFound(httpRequest *http.Request) (int, interface{}, http.Header)
- type API
- func (api *API) AddResource(resource interface{}, path string, resourceWrapperFuncs []WrapperFunc)
- func (api *API) AddRoute(method, path string, inner HandlerFunc)
- func (api *API) HttpRequestHandler(inner HandlerFunc) http.HandlerFunc
- func (api *API) Start(host string, port int) error
- func (api *API) WrapHandler(handler HandlerFunc, wrapperFuncs []WrapperFunc) HandlerFunc
- type AuthResource
- func (auth *AuthResource) AuthTokenResponse(claims map[string]interface{}) (int, interface{}, http.Header)
- func (auth *AuthResource) AuthorizationRequired(request *http.Request, inner HandlerFunc) (int, interface{}, http.Header)
- func (auth *AuthResource) IsAuthorized(request *http.Request) (bool, *jwt.Token, error)
- func (auth *AuthResource) Post(request *http.Request) (int, interface{}, http.Header)
- type AuthResponse
- type AuthValidator
- type DeleteResource
- type DummyAuthCredentials
- type DummyAuthUserInfo
- type GetResource
- type HandlerFunc
- type HeadResource
- type JSONData
- type JSONError
- type JSONMessage
- type PatchResource
- type PostResource
- type PutResource
- type StatusResponse
- type WrapperFunc
Constants ¶
View Source
const ( GET = "GET" POST = "POST" PUT = "PUT" DELETE = "DELETE" HEAD = "HEAD" PATCH = "PATCH" HTTP_UNPROCESSABLE = 422 )
View Source
const (
DEFAULT_TOKEN_DURATION = 24 * 60 // 24 hours, probably too long
)
View Source
const (
READ_BUFFER_SIZE = 1024 * 1024 // 1 meg
)
Variables ¶
This section is empty.
Functions ¶
func AuthorizationFailed ¶
canned failure response
func MethodNotAllowed ¶
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
func NewAPI ¶
func NewAPI(wrapperFuncs []WrapperFunc) *API
func (*API) AddResource ¶
func (api *API) AddResource( resource interface{}, path string, resourceWrapperFuncs []WrapperFunc, )
func (*API) AddRoute ¶
func (api *API) AddRoute( method, path string, inner HandlerFunc, )
func (*API) HttpRequestHandler ¶
func (api *API) HttpRequestHandler( inner HandlerFunc, ) http.HandlerFunc
func (*API) WrapHandler ¶
func (api *API) WrapHandler( handler HandlerFunc, wrapperFuncs []WrapperFunc, ) HandlerFunc
type AuthResource ¶
type AuthResource struct {
// contains filtered or unexported fields
}
func NewAuthResource ¶
func NewAuthResource(privateKeyPath, publicKeyPath string, tokenDuration time.Duration, validator AuthValidator) *AuthResource
func (*AuthResource) AuthTokenResponse ¶
func (auth *AuthResource) AuthTokenResponse(claims map[string]interface{}) (int, interface{}, http.Header)
func (*AuthResource) AuthorizationRequired ¶
func (auth *AuthResource) AuthorizationRequired(request *http.Request, inner HandlerFunc) (int, interface{}, http.Header)
authorization wrapper
func (*AuthResource) IsAuthorized ¶
authorization test using this method will require a reference to the auth object
type AuthResponse ¶
type AuthResponse struct {
AccessToken string `json:"access_token"`
}
type AuthValidator ¶
type AuthValidator func(request *http.Request) (bool, map[string]interface{}, StatusResponse)
type DeleteResource ¶
type DummyAuthCredentials ¶
type DummyAuthUserInfo ¶
type GetResource ¶
type HeadResource ¶
type JSONData ¶
type JSONData struct { StatusCode int `json:"status"` Data interface{} `json:"data"` }
type JSONMessage ¶
func (JSONMessage) Status ¶
func (response JSONMessage) Status() int
type PatchResource ¶
type PostResource ¶
type PutResource ¶
type StatusResponse ¶
type StatusResponse interface {
Status() int
}
func DummyAuthValidator ¶
func DummyAuthValidator(request *http.Request) (bool, map[string]interface{}, StatusResponse)
type WrapperFunc ¶
Click to show internal directories.
Click to hide internal directories.