Documentation
¶
Index ¶
- func DefaultEndpoint(c echo.Context) error
- func ErrorResponse(c echo.Context, status int, err error) error
- func LogHttpRequest(ctx context.Context, req *http.Request)
- func ParseRange(r string) (int64, int64)
- func ReceiveFileUpload(ctx context.Context, req *http.Request, location, formName string) (string, error)
- func StandardResponse(c echo.Context, status int, res interface{}) error
- func UnmashalJSONResponse(resp *http.Response, v interface{}, b *[]byte) error
- type RelevantHeaders
- type StatusObject
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultEndpoint ¶
DefaultEndpoint returns http.StatusOK if the service is able to respond to requests.
func ErrorResponse ¶
ErrorResponse reports the error and responds with an ErrorObject
func ParseRange ¶ added in v1.2.0
ParseRange extracts a byte range if specified. For specs see https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests
func ReceiveFileUpload ¶ added in v1.1.0
func ReceiveFileUpload(ctx context.Context, req *http.Request, location, formName string) (string, error)
ReceiveFileUpload handles the reception of uploads and puts the files into a specified location
func StandardResponse ¶
StandardResponse is the default way to respond to API requests
func UnmashalJSONResponse ¶ added in v1.1.0
UnmashalJSONResponse unmarshalls a generic HTTP response body into a JSON structure Pass optionally a pointer to a byte array to get the raw body of the response object written back
Types ¶
type RelevantHeaders ¶ added in v1.2.0
type RelevantHeaders struct {
Range string `header:"Range"`
UserAgent string `header:"User-Agent"`
Forwarded string `header:"Forwarded"`
XForwardedFor string `header:"X-Forwarded-For"`
XForwwardedHost string `header:"X-Forwarded-Host"`
Referer string `header:"Referer"`
}
RelevantHeaders represents the most important headers
func ExtractHeaders ¶ added in v1.2.0
func ExtractHeaders(r *http.Request) RelevantHeaders
ExtractHeaders extracts the relevant HTTP header stuff only
func (*RelevantHeaders) Ranges ¶ added in v1.2.0
func (h *RelevantHeaders) Ranges() (int64, int64)
type StatusObject ¶
type StatusObject struct {
Status int `json:"status" binding:"required"`
Message string `json:"message" binding:"required"`
RootError error `json:"-"`
}
StatusObject is used to report operation status and errors in an API request. The struct can be used as a response object or be treated as an error object
func NewErrorStatus ¶
func NewErrorStatus(s int, e error) StatusObject
NewErrorStatus initializes a new StatusObject from an error
func NewStatus ¶
func NewStatus(s int, m string) StatusObject
NewStatus initializes a new StatusObject
func (*StatusObject) Error ¶
func (so *StatusObject) Error() string
func (*StatusObject) String ¶
func (so *StatusObject) String() string