Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApiServer ¶
type ApiServer struct { PasteService api.PasteService UserService api.UserService Router *gin.Engine Server *http.Server Options ApiServerOptions }
ApiServer type provides an HTTP server that calls PasteService methods in response to HTTP requests to certain routes.
Use the `New` function to create an instance of ApiServer with the default routes.
func New ¶
func New(pSvc api.PasteService, uSvc api.UserService, opts ApiServerOptions) *ApiServer
New function returns an instance of ApiServer using provided PasteService and all the HTTP routes for manipulating pastes.
The routes are:
GET /paste/{id} - get paste by ID POST /paste - create new paste DELETE /paste/{id} - delete paste by ID POST /user/login - authenticate user POST /user/register - register new user
func (*ApiServer) ListenAndServe ¶
ListenAndServe starts an HTTP server and binds it to the provided address.
TODO: Timeouts should be configurable.
type ApiServerOptions ¶
type ApiServerOptions struct { // Addr will be passed to http.Server to listen on, see http.Server // documentation for more information. Addr string // Maximum size of the POST request body, anything larger than this will // be rejected with an error. MaxBodySize int64 }
ApiServerOptions defines various parameters needed to run the ApiServer
Click to show internal directories.
Click to hide internal directories.