Documentation ¶
Index ¶
- func InitAdminRouter(apiHelper Helper)
- func InitAdminUI(apiHelper Helper)
- func InitSourcesRouter(apiHelper Helper)
- func InitTestRouter(api Helper)
- func ReadRequest(c context.Context, w http.ResponseWriter, r heligo.Request) (records []database.Record, status int, err error)
- func SetResponseHeaders(ctx context.Context, w http.ResponseWriter, r heligo.Request, count int64) int
- func StripPrefix(r *http.Request, prefix string) *http.Request
- func TableCreateHandler(c context.Context, w http.ResponseWriter, r heligo.Request) (int, error)
- func TableDeleteHandler(c context.Context, w http.ResponseWriter, r heligo.Request) (int, error)
- func TableGetHandler(c context.Context, w http.ResponseWriter, r heligo.Request) (int, error)
- func TableListHandler(c context.Context, w http.ResponseWriter, r heligo.Request) (int, error)
- func TableUpdateHandler(c context.Context, w http.ResponseWriter, r heligo.Request) (int, error)
- func WriteBadRequest(w http.ResponseWriter, err error) (int, error)
- func WriteContent(ctx context.Context, w http.ResponseWriter, status int, content []byte) (int, error)
- func WriteError(w http.ResponseWriter, err error) (int, error)
- func WriteServerError(w http.ResponseWriter, err error) (int, error)
- type Helper
- type SmoothError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitAdminRouter ¶
func InitAdminRouter(apiHelper Helper)
func InitAdminUI ¶ added in v0.2.7
func InitAdminUI(apiHelper Helper)
func InitSourcesRouter ¶
func InitSourcesRouter(apiHelper Helper)
func InitTestRouter ¶
func InitTestRouter(api Helper)
func ReadRequest ¶ added in v0.2.6
func ReadRequest(c context.Context, w http.ResponseWriter, r heligo.Request) (records []database.Record, status int, err error)
ReadRequest reads the input data from a request and manage the preconditions. It will emit BadRequest (400), RequestEntityTooLarge (413) or UnsupportedMediaType (415) status when appropriate. Supports JSON, CSV and x-www-form-urlencoded input data.
func SetResponseHeaders ¶ added in v0.2.5
func SetResponseHeaders(ctx context.Context, w http.ResponseWriter, r heligo.Request, count int64) int
SetResponseHeaders sets the response headers (for now Content-Range and Content-Location). It returns a status != 0 if some contraints are not satisfied and we need to include an error status in the response (eg 416 for RequestedRangeNotSatisfiable)
func StripPrefix ¶ added in v0.2.7
StripPrefix returns a new request with the URL path stripped from a prefix. It returns nil if the URL path has nbot been stripped. Taken from the handler version in the standard lib: http.StripPrefix.
func TableCreateHandler ¶
func TableDeleteHandler ¶
func TableGetHandler ¶
func TableListHandler ¶
func TableUpdateHandler ¶
func WriteBadRequest ¶
func WriteBadRequest(w http.ResponseWriter, err error) (int, error)
WriteBadRequest writes a BadRequest or StatusRequestEntityTooLarge status
func WriteContent ¶ added in v0.2.5
func WriteContent(ctx context.Context, w http.ResponseWriter, status int, content []byte) (int, error)
WriteContent writes the response and its content type
func WriteError ¶
func WriteError(w http.ResponseWriter, err error) (int, error)
WriteError is the more general error function, combining the previous two.
func WriteServerError ¶
func WriteServerError(w http.ResponseWriter, err error) (int, error)
WriteServerError write a status related to a database error
Types ¶
type Helper ¶ added in v0.2.3
type Helper interface { GetDBE() *database.DbEngine GetDatabase(context.Context, string) (*database.Database, error) GetMainDatabase(context.Context) (*database.Database, error) GetRouter() *heligo.Router MiddlewareStd() heligo.Middleware MiddlewareDBE() heligo.Middleware MiddlewareWithDbName(string) heligo.Middleware BaseAdminURL() string BaseAPIURL() string HasShortAPIURL() bool SessionStatistics() authn.SessionStatistics }