api

package
v0.0.0-...-c1adc34 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2019 License: BSD-3-Clause Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Initialize

func Initialize(logger *logrus.Logger) (Router, Lookuper)

Initialize service Builder and Lookuper

func RegisterEndpoints

func RegisterEndpoints(r Router, s Lookuper)

RegisterEndpoints bind endpoints to the router

Types

type Endpoint

type Endpoint func(*http.Request) (interface{}, error)

An Endpoint is a service endpoint that receives a request and returns either a successfully processed response body or an Error. In either case both responses are encoded and returned to the user with the appropriate status code

type Error

type Error struct {
	XMLName    xml.Name `json:"-" xml:"error"`
	Message    string   `json:"message,omitempty" xml:"message,omitempty"`
	StatusCode int      `json:"status,omitempty" xml:"status,omitempty"`
	Err        string   `json:"err,omitempty" xml:"err,omitempty"`
}

Error is a generic API error

func NewError

func NewError(message string, statusCode int, err error) *Error

NewError is a generic http error type used for all error responses

func (*Error) Error

func (e *Error) Error() string

Error returns a string representation of the error and helps to satisfy the error interface

func (*Error) Log

func (e *Error) Log(log *logrus.Entry) *Error

Log will log the Error before returning it

type Lookuper

type Lookuper interface {
	Lookup(r *http.Request) (interface{}, error)
	Healthcheck(r *http.Request) (interface{}, error)
}

Lookuper defines all functionality for an email verification lookup API service

func NewLookuper

func NewLookuper(log *logrus.Logger, hostname, sourceAddr string) Lookuper

NewLookuper generates a new email verification lookup API service

type Router

type Router interface {
	HandleStatic(path string) *mux.Route
	HandleEndpoint(pattern string, endpoint Endpoint) *mux.Route
	ListenAndServe(port string) error
}

Router defines all functionality for our api service router

func NewRouter

func NewRouter(rateLimit bool) Router

NewRouter generates a new Router that will be used to bind handlers to the *mux.Router

Jump to

Keyboard shortcuts

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