handlers

package
v0.0.0-...-e25b398 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HandlerResponse

type HandlerResponse struct {
	Service     string
	Function    string
	StatusCode  int
	Payload     interface{}
	Err         error
	FieldErrors []common.FieldError
}

HandlerResponse structure.

func Created

func Created(payload interface{}) HandlerResponse

Created builds and returns a handler response for a successful create operation.

func InternalServerError

func InternalServerError(serviceName, functionName string, err error) HandlerResponse

InternalServerError builds and returns a handler response for an internal error.

func NoContent

func NoContent() HandlerResponse

NoContent builds and returns a handler response for a successful operation with no content returned.

func NotFound

func NotFound(serviceName, functionName string, err error) HandlerResponse

NotFound builds and returns a handler response for a resource not found error.

func Ok

func Ok(payload interface{}) HandlerResponse

Ok builds and returns a handler response for a successful operation.

func UnprocessableEntity

func UnprocessableEntity(serviceName, functionName string, fieldErrors []common.FieldError) HandlerResponse

UnprocessableEntity builds and returns a handler response for a model with invalid state.

type MovieHandler

type MovieHandler interface {
	// GetAllMovies returns a handler response containing all found movies
	// and any additional information.
	GetAllMovies() HandlerResponse

	// GetMovieById returns a handler response containing the movie found for a given id
	// and any additional information.
	GetMovieById(id int) HandlerResponse

	// CreateMovie creates a movie and returns a handler response containing the created movie
	// and any additional information.
	CreateMovie(newMovie *models.Movie) HandlerResponse

	// UpdateMovie updates a movie and returns a handler response containing the updated movie
	// and any additional information.
	UpdateMovie(id int, movieToUpdate *models.Movie) HandlerResponse

	// DeleteMovieById deletes a movie for a given id and returns a handler response containing
	// the results of the operation.
	DeleteMovieById(id int) HandlerResponse
}

MovieHandler contract.

func MovieHandlerImpl

func MovieHandlerImpl(r repositories.MovieRepository) MovieHandler

MovieHandlerImpl builds and returns a movie handler implementation.

Jump to

Keyboard shortcuts

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