http

package
v0.0.1-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2021 License: MIT Imports: 12 Imported by: 0

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

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

func (h *ApiServer) ListenAndServe() error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL