handler

package
v0.0.0-...-f21bc9d Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package handler provides endpoints for a simple CRUD API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(bolter db.Bolter, col string) http.HandlerFunc

Delete returns an http.HandlerFunc which extract from the request params an ID of the item to remove from the database.

Returns a non-2xx status code when: * There's a problem while removing the item from the database.

func Get

func Get(bolter db.Bolter, col string, m model.Modeler) http.HandlerFunc

Get returns an http.HandlerFunc which extracts from the request params an ID with which it tries to find an item in the database.

Returns a non-2xx status code when: * There's a problem getting the item from the database. * There's a problem unmarshaling the item. * There's a problem encoding the result to JSON.

func GetAuthors

func GetAuthors(bolter db.Bolter, col string, m model.Modeler) http.HandlerFunc

GetAuthors returns an http.HandlerFunc which extracts all the authors from the specified collection of the database.

Returns a non-2xx status code when: * There's a problem while getting the authors from the database. * There's a problem encoding the result to JSON.

func GetBooks

func GetBooks(bolter db.Bolter, col string, m model.Modeler) http.HandlerFunc

GetBooks returns an http.HandlerFunc which extracts all the books from the specified collection of the database.

Returns a non-2xx status code when: * There's a problem while getting the books from the database. * There's a problem encoding the result to JSON.

func GetSagas

func GetSagas(bolter db.Bolter, col string, m model.Modeler) http.HandlerFunc

GetSagas returns an http.HandlerFunc which extracts all the sagas from the specified collection of the database.

Returns a non-2xx status code when: * There's a problem while getting the sagas from the database. * There's a problem encoding the result to JSON.

func Post

func Post(bolter db.Bolter, col string, m model.Modeler) http.HandlerFunc

Post returns an http.HandlerFunc that tries to extract a new item from the body of the request.

Returns a non-2xx status code when: * The request body is too large. * There's a problem closing the request body. * There's a problem marshaling the item. * There's a problem adding the new item to the database. * There's a problem encoding the result to JSON.

func Put

func Put(bolter db.Bolter, col string, m model.Modeler) http.HandlerFunc

Put returns an http.HandlerFunc that tries to update an existing item on the database with the request body.

Returns a non-2xx status code when: * The request body is too large. * There's a problem closing the request body. * There's a problem unmarshaling the item. * There's a problem while updating the item on the database. * There's a problem encoding the result to JSON.

Types

This section is empty.

Directories

Path Synopsis
internal
tdb

Jump to

Keyboard shortcuts

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