Documentation ¶
Index ¶
Constants ¶
View Source
const ( //AuthFailStatus - failure status code AuthFailStatus = 403 //AuthSuccessStatus - success status code AuthSuccessStatus = 200 //KeyLength - valid length of a api-key KeyLength = 36 )
Variables ¶
View Source
var ( //AuthFailureResponse - failure response for invalid key AuthFailureResponse = []byte(`{"error": "no valid key found"}`) )
View Source
var (
HeaderKeyName = "X-API-KEY"
)
Functions ¶
This section is empty.
Types ¶
type APIKeyCheckHandler ¶
APIKeyCheckHandler - type of our handler function
type APIKeyCheckMiddleware ¶
type APIKeyCheckMiddleware struct {
Keycheck KeyChecker
}
APIKeyCheckMiddleware - our middleware struct
func NewAPIKeyCheckMiddleware ¶
func NewAPIKeyCheckMiddleware(url string) *APIKeyCheckMiddleware
NewAPIKeyCheckMiddleware - creates a new instance of our middleware
func (*APIKeyCheckMiddleware) Handler ¶
func (s *APIKeyCheckMiddleware) Handler() martini.Handler
Handler - returns the handler function as a martini.Handler type
type ClientDoer ¶
ClientDoer - an interface for a http Client.Do
type KeyChecker ¶
type KeyChecker interface { SetClient(ClientDoer) Check(string) (res *http.Response, err error) }
KeyChecker - an interface for something that can check a key
Click to show internal directories.
Click to hide internal directories.