core

package module
v0.0.0-...-f484cb6 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

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

New doc ...

func (*API) AddMapMethod

func (api *API) AddMapMethod(key string, methods []string)

AddMapMethod doc ...

func (API) GetHeaderValueBool

func (api API) GetHeaderValueBool(key string, r *http.Request) (bool, error)

GetHeaderValueBool doc ...

func (API) GetHeaderValueFloat64

func (api API) GetHeaderValueFloat64(key string, r *http.Request) (float64, error)

GetHeaderValueFloat64 doc ...

func (API) GetHeaderValueInt

func (api API) GetHeaderValueInt(key string, r *http.Request) (int, error)

GetHeaderValueInt doc ...

func (API) GetHeaderValueInt64

func (api API) GetHeaderValueInt64(key string, r *http.Request) (int64, error)

GetHeaderValueInt64 doc ...

func (API) GetHeaderValueString

func (api API) GetHeaderValueString(key string, r *http.Request) (string, error)

GetHeaderValueString doc ...

func (API) GetQueryParamValueBool

func (api API) GetQueryParamValueBool(queryParamName string, r *http.Request) (bool, error)

GetQueryParamValueBool ...

func (API) GetQueryParamValueFloat64

func (api API) GetQueryParamValueFloat64(queryParamName string, r *http.Request) (float64, error)

GetQueryParamValueFloat64 ...

func (API) GetQueryParamValueInt

func (api API) GetQueryParamValueInt(queryParamName string, r *http.Request) (int, error)

GetQueryParamValueInt ...

func (API) GetQueryParamValueInt64

func (api API) GetQueryParamValueInt64(queryParamName string, r *http.Request) (int64, error)

GetQueryParamValueInt64 ...

func (API) GetQueryParamValueString

func (api API) GetQueryParamValueString(queryParamName string, r *http.Request) (string, error)

GetQueryParamValueString ...

func (API) GetRouteVarValueBool

func (api API) GetRouteVarValueBool(urlVarName string, r *http.Request) (bool, error)

GetRouteVarValueBool ...

func (API) GetRouteVarValueFloat64

func (api API) GetRouteVarValueFloat64(urlVarName string, r *http.Request) (float64, error)

GetRouteVarValueFloat64 ...

func (API) GetRouteVarValueInt

func (api API) GetRouteVarValueInt(urlVarName string, r *http.Request) (int, error)

GetRouteVarValueInt ...

func (API) GetRouteVarValueInt64

func (api API) GetRouteVarValueInt64(urlVarName string, r *http.Request) (int64, error)

GetRouteVarValueInt64 ...

func (API) GetRouteVarValueString

func (api API) GetRouteVarValueString(urlVarName string, r *http.Request) (string, error)

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

func (api API) UnmarshalBody(v interface{}, r *http.Request) error

UnmarshalBody doc ...

func (*API) ValidateBasicToken

func (api *API) ValidateBasicToken(token string) (client, secret string, valid bool)

ValidateBasicToken doc ...

func (*API) ValidateCustomToken

func (api *API) ValidateCustomToken(token string, customValidator CustomTokenValidator) (json.RawMessage, bool)

ValidateCustomToken doc ...

func (*API) ValidateMethods

func (api *API) ValidateMethods(keyMapMethod, method string) bool

ValidateMethods doc ...

func (*API) ValidateRequest

func (api *API) ValidateRequest(r *http.Request) (*RequestData, error)

ValidateRequest doc ...

func (API) Vars

func (api API) Vars(r *http.Request) map[string]string

Vars returns the route variables for the current request, if any.

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 MapMethods

type MapMethods map[string][]string

MapMethods doc ...

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 ...

func (*RequestData) AddHeader

func (data *RequestData) AddHeader(key, value string)

AddHeader doc

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

type ResponseFormatted struct {
	Headers    map[string]string
	StatusCode int
	Data       interface{}
}

ResponseFormatted ...

type ResponseType

type ResponseType string

ResponseType contains all the response types identiers

Jump to

Keyboard shortcuts

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