package
3.3.2+incompatible
Repository: https://github.com/ant0ine/go-json-rest.git
Documentation: pkg.go.dev

# Packages

Utility functions to help writing tests for a Go-Json-Rest app Go comes with net/http/httptest to help writing test for an http server.
Special Trie implementation for HTTP routing.

# Functions

Delete is a shortcut method that instantiates a DELETE route.
Error produces an error response in JSON with the following structure, '{"Error":"My error message"}' The standard plain text net/http Error helper can still be called like this: http.Error(w, "error message", code).
Get is a shortcut method that instantiates a GET route.
Head is a shortcut method that instantiates a HEAD route.
MakeRouter returns the router app.
NewApi makes a new Api object.
NotFound produces a 404 response with the following JSON, '{"Error":"Resource not found"}' The standard plain text net/http NotFound helper can still be called like this: http.NotFound(w, r.Request).
Options is a shortcut method that instantiates an OPTIONS route.
Patch is a shortcut method that instantiates a PATCH route.
Post
Post is a shortcut method that instantiates a POST route.
Put is a shortcut method that instantiates a PUT route.
WrapMiddlewares calls the MiddlewareFunc methods in the reverse order and returns an HandlerFunc ready to be executed.

# Constants

CombinedLogFormat is the NCSA extended/combined log format.
CommonLogFormat is the Common Log Format (CLF).
DefaultLogFormat is the default format, colored output and response time, convenient for development.

# Variables

Defines a stack of middlewares that should be common to most of the middleware stacks.
Defines a stack of middlewares convenient for development.
Defines a stack of middlewares convenient for production.
ErrJsonPayloadEmpty is returned when the JSON payload is empty.
This allows to customize the field name used in the error response payload.

# Structs

AccessLogApacheMiddleware produces the access log following a format inspired by Apache mod_log_config.
AccessLogJsonMiddleware produces the access log with records written as JSON.
AccessLogJsonRecord is the data structure used by AccessLogJsonMiddleware to create the JSON records.
Api defines a stack of Middlewares and an App.
AuthBasicMiddleware provides a simple AuthBasic implementation.
ContentTypeCheckerMiddleware verifies the request Content-Type header and returns a StatusUnsupportedMediaType (415) HTTP error response if it's incorrect.
CorsInfo contains the CORS request info derived from a rest.Request.
CorsMiddleware provides a configurable CORS implementation.
GzipMiddleware is responsible for compressing the payload with gzip and setting the proper headers when supported by the client.
IfMiddleware evaluates at runtime a condition based on the current request, and decides to execute one of the other Middleware based on this boolean.
JsonIndentMiddleware provides JSON encoding with indentation.
JsonpMiddleware provides JSONP responses on demand, based on the presence of a query string argument specifying the callback name.
PoweredByMiddleware adds the "X-Powered-By" header to the HTTP response.
RecorderMiddleware keeps a record of the HTTP status code of the response, and the number of bytes written.
RecoverMiddleware catches the panic errors that occur in the wrapped HandleFunc, and convert them to 500 responses.
Request inherits from http.Request, and provides additional methods.
Route defines a route as consumed by the router.
Status contains stats and status information.
StatusMiddleware keeps track of various stats about the processed requests.
TimerMiddleware computes the elapsed time spent during the execution of the wrapped handler.

# Interfaces

App defines the interface that an object should implement to be used as an app in this framework stack.
Middleware defines the interface that objects must implement in order to wrap a HandlerFunc and be used in the middleware stack.
A ResponseWriter interface dedicated to JSON HTTP response.

# Type aliases

AccessLogFormat defines the format of the access log record.
AppSimple is an adapter type that makes it easy to write an App with a simple function.
HandlerFunc defines the handler function.
MiddlewareSimple is an adapter type that makes it easy to write a Middleware with a simple function.