api

package
v0.0.0-...-5e9bb57 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBadRequest return status 400 Bad Request for malformed request body.
	ErrBadRequest = &ErrResponse{StatusCode: http.StatusBadRequest, StatusText: http.StatusText(http.StatusBadRequest)}

	// ErrNotFound returns status 404 Not Found for invalid resource request.
	ErrNotFound = &ErrResponse{StatusCode: http.StatusNotFound, StatusText: http.StatusText(http.StatusNotFound)}

	// ErrInternalServerError returns status 500 Internal Server Error.
	ErrInternalServerError = &ErrResponse{StatusCode: http.StatusInternalServerError, StatusText: http.StatusText(http.StatusInternalServerError)}
)

Functions

func StartHTTPServer

func StartHTTPServer(port, dbDir string) error

StartHTTPServer starts HTTP server on a given port, with database being used at dbDir.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

API provides the application HTTP API

func NewAPI

func NewAPI(repo service.PaymentsRepository) (*API, error)

NewAPI creates a new API instance

func (*API) Router

func (api *API) Router() *chi.Mux

Router provides API routes.

type ErrResponse

type ErrResponse struct {
	Error      error  `json:"-"`      // low-level runtime error
	StatusCode int    `json:"-"`      // http response status code
	StatusText string `json:"status"` // user-level status message
}

ErrResponse renderer type for handling all sorts of errors.

func (*ErrResponse) Render

func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error

Render sets the application-specific error code in AppCode.

type PaymentResource

type PaymentResource struct {
	// contains filtered or unexported fields
}

PaymentResource implements payments management handler

func NewPaymentResource

func NewPaymentResource(repo service.PaymentsRepository) *PaymentResource

NewPaymentResource creates and returns a payments resource.

type Server

type Server struct {
	*http.Server
}

Server is the HTTP server of the Payments API.

Jump to

Keyboard shortcuts

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