Documentation ¶
Overview ¶
Package handler provides endpoints for a simple CRUD API.
Index ¶
- func Delete(bolter db.Bolter, col string) http.HandlerFunc
- func Get(bolter db.Bolter, col string, m model.Modeler) http.HandlerFunc
- func GetAuthors(bolter db.Bolter, col string, m model.Modeler) http.HandlerFunc
- func GetBooks(bolter db.Bolter, col string, m model.Modeler) http.HandlerFunc
- func GetSagas(bolter db.Bolter, col string, m model.Modeler) http.HandlerFunc
- func Post(bolter db.Bolter, col string, m model.Modeler) http.HandlerFunc
- func Put(bolter db.Bolter, col string, m model.Modeler) http.HandlerFunc
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.