api

package
v0.11.9 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package api provides API endpoints and controllers.

Index

Constants

This section is empty.

Variables

View Source
var ErrCDCDisabled = etre.Error{
	Type:       "cdc-disabled",
	HTTPStatus: http.StatusNotImplemented,
	Message:    "CDC disabled",
}
View Source
var ErrDuplicateEntity = etre.Error{
	Type:       "duplicate-entity",
	HTTPStatus: http.StatusConflict,
	Message:    "cannot insert or update entity because identifying labels conflict with another entity",
}
View Source
var ErrInternal = etre.Error{
	Type:       "internal-error",
	HTTPStatus: http.StatusInternalServerError,
	Message:    "internal server error",
}
View Source
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,
}
View Source
var ErrInvalidParam = etre.Error{
	Type:       "invalid-param",
	HTTPStatus: http.StatusBadRequest,
	Message:    "missing parameter",
}
View Source
var ErrInvalidQuery = etre.Error{
	Type:       "invalid-query",
	HTTPStatus: http.StatusBadRequest,
	Message:    "invalid query",
}
View Source
var ErrMissingParam = etre.Error{
	Type:       "missing-param",
	HTTPStatus: http.StatusBadRequest,
	Message:    "missing parameter",
}
View Source
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,
}
View Source
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

func NewAPI(appCtx app.Context) *API

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) Router

func (api *API) Router() *echo.Echo

func (*API) Run

func (api *API) Run() error

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) Stop

func (api *API) Stop() error

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

func (api *API) WriteResult(c echo.Context, v interface{}, err error) (int, interface{})

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.

Jump to

Keyboard shortcuts

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