Documentation
¶
Index ¶
Constants ¶
const ( ErrorDateRequired = "DateHeaderRequired" ErrorDateInvalid = "DateHeaderInvalid" )
const ( ErrorRequestBodyInvalid = "RequestBodyInvalid" ErrorRequestInvalid = "InvalidRequest" ErrorRequestFailed = "RequestFailed" HeaderGoblDate = "x-gobl-date" HeaderGoblSig = "x-gobl-signature" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Normalize ¶
type Normalize struct { }
Normalize Middleware: It implements the ServeHTTP interface for negroni middleware. The function is to evaluate the incoming request and validate/store the required headers
func NewNormalize ¶
func NewNormalize() *Normalize
func (Normalize) ServeHTTP ¶
func (n Normalize) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
ServeHTTP is the interface implementation for negroni middleware
type Request ¶
type Request struct { Headers http.Header RouteParameters httprouter.Params Body io.ReadSeeker Host string Path string Method string Query url.Values Client *http.Client }
Request provides a starndardized way of accessing incoming requests We standardize information both for receiving and sending.
Context: It implements context functions for the context.Context package so that the rest of gobl can access the standardized parameters via the http.Request context
func NewRequest ¶
func RequestFromContext ¶
RequestFromContext returns the reqest that has been stored in a context
type Response ¶
type Response struct { // Data is API payload Data map[string]interface{} `json:"data,omitempty"` // Error holds any errors that were encountered processing the request Error error `json:"-"` // HTTPCode allows individual handlers to indiciate the appropriate http status code to return HTTPCode int `json:"-"` }
Response is the standardized response format sent from the API
func (*Response) Write ¶
func (r *Response) Write(rw http.ResponseWriter)
Write the standardized response to the given response writer
type Route ¶
type Route struct { // Method is the HTTP method to listen on Method string // Path indictes the URL path. Wildcards in the form of :segment are supported // For more information see: // https://github.com/julienschmidt/httprouter Path string // Handler to use for this route Handler RouteHandler }
Route defines a single endpoint
type RouteHandler ¶
type RouteHandler func(*Request, httprouter.Params) Response
RouteHandler is the definition functions must meet to handle incoming requests