keycheck

package
v0.0.155 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2016 License: GPL-2.0, GPL-2.0 Imports: 3 Imported by: 0

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

type APIKeyCheckHandler func(log *log.Logger, res http.ResponseWriter, req *http.Request)

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

type ClientDoer interface {
	Do(req *http.Request) (resp *http.Response, err error)
}

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

func New

func New(url string) KeyChecker

New - a new keychecker targetted at the given url

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL