Documentation ¶
Overview ¶
Package api provides API endpoints and controllers.
Index ¶
- Variables
- type API
- func (api *API) Router() *echo.Echo
- func (api *API) Run() error
- func (api *API) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (api *API) Stop() error
- func (api *API) Use(middleware ...echo.MiddlewareFunc)
- func (api *API) WriteResult(c echo.Context, v interface{}, err error) (int, interface{})
Constants ¶
This section is empty.
Variables ¶
var ErrCDCDisabled = etre.Error{ Type: "cdc-disabled", HTTPStatus: http.StatusNotImplemented, Message: "CDC disabled", }
var ErrDuplicateEntity = etre.Error{ Type: "duplicate-entity", HTTPStatus: http.StatusConflict, Message: "cannot insert or update entity because identifying labels conflict with another entity", }
var ErrInternal = etre.Error{ Type: "internal-error", HTTPStatus: http.StatusInternalServerError, Message: "internal server error", }
var ErrInvalidContent = etre.Error{ Message: "HTTP payload is not valid JSON: []etre.Entity for POST or etre.Entity for PUT", Type: "invalid-content", HTTPStatus: http.StatusBadRequest, }
var ErrInvalidParam = etre.Error{ Type: "invalid-param", HTTPStatus: http.StatusBadRequest, Message: "missing parameter", }
var ErrInvalidQuery = etre.Error{ Type: "invalid-query", HTTPStatus: http.StatusBadRequest, Message: "invalid query", }
var ErrMissingParam = etre.Error{ Type: "missing-param", HTTPStatus: http.StatusBadRequest, Message: "missing parameter", }
var ErrNoContent = etre.Error{ Message: "no entities provided (PUT or POST with zero-length HTTP payload or JSON array)", Type: "no-content", HTTPStatus: http.StatusBadRequest, }
var ErrNotFound = etre.Error{ Type: "entity-not-found", HTTPStatus: http.StatusNotFound, Message: "entity not found", }
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API provides controllers for endpoints it registers with a router.
func NewAPI ¶
NewAPI godoc @title Etre API @version 1 @description Etre is an entity API for managing primitive entities with labels. @contact.url https://github.com/square/etre @license.name Apache 2.0 @license.url http://www.apache.org/licenses/LICENSE-2.0
func (*API) ServeHTTP ¶
func (api *API) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP allows the API to statisfy the http.HandlerFunc interface.
func (*API) Use ¶
func (api *API) Use(middleware ...echo.MiddlewareFunc)
Use adds middleware to the echo web server in the API. See https://echo.labstack.com/middleware for more details.
func (*API) WriteResult ¶
Return an etre.WriteResult for all writes, successful of not. v are the writes, if any, from entity.Store calls, which is why it can be different types. v and err are _not_ mutually exclusive; writes can be partially successful.