Documentation ¶
Index ¶
- Constants
- func DecodeEMFError(r io.Reader, eh errors.EMFErrorHandler) (e *errors.EMFErrorType)
- func NewEMFErrorHandler(c echo.Context, isDebug bool, opts ...errors.HandlerOption) (eh *errors.EMFErrorHandlerType)
- type Client
- type EMFContext
- type EMFContextType
- func (ctx *EMFContextType) ErrorHandler() errors.EMFErrorHandler
- func (ctx *EMFContextType) GetClaim(claim string) (c string, err error)
- func (ctx *EMFContextType) GetLimitAndOffset() (limit int, offset int, err error)
- func (ctx *EMFContextType) GetRequestHandler() RequestHandler
- func (ctx *EMFContextType) GetRequestID() string
- func (ctx *EMFContextType) GetRequestLimited(domain, path string) (req *http.Request, err error)
- func (ctx *EMFContextType) IsDebug() bool
- func (ctx *EMFContextType) Logger() echo.Logger
- func (ctx *EMFContextType) NewError(code string, data map[string]interface{}, errors ...error) error
- type LoggerlessRequestHandler
- type Option
- type RHOption
- type RequestHandler
- type RequestHandlerType
- func (rh RequestHandlerType) ErrorHandler() errors.EMFErrorHandler
- func (rh RequestHandlerType) GetDefaultLimit() (limit int)
- func (rh RequestHandlerType) GetDomain(component string) (domain string)
- func (rh RequestHandlerType) GetMaxLimit() (limit int)
- func (rh RequestHandlerType) GetRequest(domain, path string) (req *http.Request, err error)
- func (rh RequestHandlerType) GobRequest(method, domain, path string, input interface{}) (req *http.Request, err error)
- func (rh RequestHandlerType) Header() http.Header
- func (rh RequestHandlerType) InitRequest(encodingType string, method string, domain string, path string, ...) (req *http.Request, err error)
- func (rh RequestHandlerType) IsDebug() bool
- func (rh RequestHandlerType) JSONRequest(method, domain, path string, input interface{}) (req *http.Request, err error)
- func (rh RequestHandlerType) Logger() echo.Logger
- func (rh RequestHandlerType) NewError(code string, data map[string]interface{}, errors ...error) error
- func (rh RequestHandlerType) Requester(method string, component string, path string, input interface{}, ...) (err error)
- func (rh RequestHandlerType) SendRequest(req *http.Request, output interface{}) (err error)
Constants ¶
const EncodingGob = "Gob"
EncodingGob is the Gob Input encoding string for c.Requester
const EncodingJSON = "JSON"
EncodingJSON is the JSON Input encoding string for c.Requester
const MethodPostGob = "POST-GOB"
MethodPostGob is the HTTP Method string to enable Gob encoding for a POST request
const MethodPutGob = "PUT-GOB"
MethodPutGob is the HTTP Method string to enable Gob encoding for a POST request
Variables ¶
This section is empty.
Functions ¶
func DecodeEMFError ¶
func DecodeEMFError(r io.Reader, eh errors.EMFErrorHandler) (e *errors.EMFErrorType)
DecodeEMFError is a helper function to read a request body and parse it into a EMFErrorType object or return an error, also as a EMFErrorType
func NewEMFErrorHandler ¶
func NewEMFErrorHandler(c echo.Context, isDebug bool, opts ...errors.HandlerOption) (eh *errors.EMFErrorHandlerType)
NewEMFErrorHandler is a variadic constructor for a EMFErrorHandler.
Types ¶
type EMFContext ¶
type EMFContext interface { echo.Context LoggerlessRequestHandler GetClaim(claim string) (c string, err error) GetRequestID() string GetRequestHandler() RequestHandler GetLimitAndOffset() (limit int, offset int, err error) GetRequestLimited(domain, path string) (req *http.Request, err error) }
EMFContext is the Interface which is passed into each EMF request handler as part of each request
type EMFContextType ¶
type EMFContextType struct { echo.Context RequestHandler }
EMFContextType is the default implementation of the EMFContext interface
func NewEMFContext ¶
func NewEMFContext(c echo.Context, cfg configurer.ConfigReader, opts ...Option) (ctx *EMFContextType)
NewEMFContext is a variadic constructor for a EMFContext.
func (*EMFContextType) ErrorHandler ¶
func (ctx *EMFContextType) ErrorHandler() errors.EMFErrorHandler
ErrorHandler is a helper function to make an ErrorHandler object from the Context and return it
func (*EMFContextType) GetClaim ¶
func (ctx *EMFContextType) GetClaim(claim string) (c string, err error)
GetClaim is a helper function to handle type and map checking for JWT Claims
func (*EMFContextType) GetLimitAndOffset ¶
func (ctx *EMFContextType) GetLimitAndOffset() (limit int, offset int, err error)
GetLimitAndOffset is a helper function to parse limit and offset query parameters and return them
func (*EMFContextType) GetRequestHandler ¶
func (ctx *EMFContextType) GetRequestHandler() RequestHandler
GetRequestHandler is a getter for the RequestHandler object embedded in the context
func (*EMFContextType) GetRequestID ¶
func (ctx *EMFContextType) GetRequestID() string
GetRequestID is a helper function to expose the RequestID Header
func (*EMFContextType) GetRequestLimited ¶
func (ctx *EMFContextType) GetRequestLimited(domain, path string) (req *http.Request, err error)
GetRequestLimited is the method to set up a HTTP Get request with no body and a limit Query Parameter
func (*EMFContextType) IsDebug ¶
func (ctx *EMFContextType) IsDebug() bool
IsDebug is a helper function to provide access to the Debug Mode config flag
func (*EMFContextType) Logger ¶
func (ctx *EMFContextType) Logger() echo.Logger
Logger is wrapper to disambiguate the Logger method
type LoggerlessRequestHandler ¶
type LoggerlessRequestHandler interface { Requester(method, component, path string, input, output interface{}) error InitRequest( encodingType string, method string, domain string, path string, input interface{}, ) (req *http.Request, err error) GetRequest(component, path string) (*http.Request, error) JSONRequest(method, component, path string, input interface{}) (*http.Request, error) GobRequest(method, component, path string, input interface{}) (*http.Request, error) SendRequest(request *http.Request, output interface{}) error Header() http.Header GetDomain(component string) (domain string) IsDebug() bool ErrorHandler() errors.EMFErrorHandler NewError(code string, data map[string]interface{}, errors ...error) error GetDefaultLimit() (limit int) GetMaxLimit() (limit int) }
LoggerlessRequestHandler is the minimum method set for the Requester family of functions
type Option ¶
type Option func(*EMFContextType)
Option provides the client a callback that is used to dynamically specify attributes for a EMFContext.
func WithContextClient ¶
WithContextClient is used to specify the HTTP Client for the Requester to use.
func WithRequestHandler ¶
func WithRequestHandler(rh RequestHandler) Option
WithRequestHandler is used to modify the default RequestHandler object
type RHOption ¶
type RHOption func(*RequestHandlerType)
RHOption provides the client a callback that is used to dynamically specify attributes for a RequestHandler.
func WithDebugMode ¶
func WithDebugMode() RHOption
WithDebugMode enables debug mode on the RequestHandler
func WithHTTPClient ¶
WithHTTPClient is used for specifying the HTTP Client for the Requester to use.
func WithHeaders ¶
WithHeaders configures the Authorization and other HTTP headers for a requestHandler
type RequestHandler ¶
type RequestHandler interface { Logger() echo.Logger LoggerlessRequestHandler }
RequestHandler is the minimum method set for the Requester family of functions
type RequestHandlerType ¶
type RequestHandlerType struct {
// contains filtered or unexported fields
}
RequestHandlerType is the minimum struct for sending requests with Requester
func NewRequestHandler ¶
func NewRequestHandler(cfg configurer.ConfigReader, logger echo.Logger, opts ...RHOption) (rh *RequestHandlerType)
NewRequestHandler is a variadic constructor for a RequestHandler.
func (RequestHandlerType) ErrorHandler ¶
func (rh RequestHandlerType) ErrorHandler() errors.EMFErrorHandler
ErrorHandler is a helper function to make an ErrorHandler object from the Context and return it
func (RequestHandlerType) GetDefaultLimit ¶
func (rh RequestHandlerType) GetDefaultLimit() (limit int)
GetDefaultLimit is a helper function to expose fetching the default limit from the config file
func (RequestHandlerType) GetDomain ¶
func (rh RequestHandlerType) GetDomain(component string) (domain string)
GetDomain is a helper function to expose fetching domains from the config file
func (RequestHandlerType) GetMaxLimit ¶
func (rh RequestHandlerType) GetMaxLimit() (limit int)
GetMaxLimit is a helper function to expose fetching the maximum limit from the config file
func (RequestHandlerType) GetRequest ¶
func (rh RequestHandlerType) GetRequest(domain, path string) (req *http.Request, err error)
GetRequest is the method to set up a HTTP Get request with no body
func (RequestHandlerType) GobRequest ¶
func (rh RequestHandlerType) GobRequest( method, domain, path string, input interface{}, ) (req *http.Request, err error)
GobRequest is the method to set up a Gob-encoded HTTP Request
func (RequestHandlerType) Header ¶
func (rh RequestHandlerType) Header() http.Header
Header is a helper function to expose the http.Header object
func (RequestHandlerType) InitRequest ¶
func (rh RequestHandlerType) InitRequest( encodingType string, method string, domain string, path string, input interface{}, ) (req *http.Request, err error)
InitRequest is the method to initialize any HTTP request for use with rh.SendRequest
func (RequestHandlerType) IsDebug ¶
func (rh RequestHandlerType) IsDebug() bool
IsDebug is a helper function to provide access to the Debug Mode config flag
func (RequestHandlerType) JSONRequest ¶
func (rh RequestHandlerType) JSONRequest( method, domain, path string, input interface{}, ) (req *http.Request, err error)
JSONRequest is the method to set up a JSON-encoded HTTP Request
func (RequestHandlerType) Logger ¶
func (rh RequestHandlerType) Logger() echo.Logger
Logger is a helper function to wrap ErrorHandler.Logger
func (RequestHandlerType) NewError ¶
func (rh RequestHandlerType) NewError(code string, data map[string]interface{}, errors ...error) error
NewError is a helper function to wrap ErrorHandler.NewError
func (RequestHandlerType) Requester ¶
func (rh RequestHandlerType) Requester( method string, component string, path string, input interface{}, output interface{}, ) (err error)
Requester is a method to send HTTP client requests to other components Uses the same interface as before, now with modular request generation
func (RequestHandlerType) SendRequest ¶
func (rh RequestHandlerType) SendRequest( req *http.Request, output interface{}, ) (err error)
SendRequest is a method to send HTTP client requests to other components