api

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultLimit = 20
View Source
const DefaultOffset = 0

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Router chi.Router
	// contains filtered or unexported fields
}

API provides a struct to wrap the api around

func New

func New(ctx context.Context, cfg *config.Config, r chi.Router, idc *identity.Client, rsp responder, g generator, d datastore, ds datasetAPIClient, c cantabularClient) *API

New creates and initialises a new API

func (*API) ParseRequest

func (api *API) ParseRequest(body io.Reader, req interface{}) error

ParseRequest attemts to read unmarshal a request body into a request object, returning an appropriate error on failure. 'req' must be a pointer to a struct. ParseRequest will also attempt to call the request's Valid() function if it has one and will throw an error if it fails

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error is the packages error type

func (Error) Error

func (e Error) Error() string

Error satisfies the standard library Go error interface

func (Error) LogData

func (e Error) LogData() map[string]interface{}

LogData satisfies the dataLogger interface which is used to recover log data from an error

func (Error) Message

func (e Error) Message() string

Message satisfies the messanger interface which is used to specify a response to be sent to the caller in place of the error text for a given error. This is useful when you don't want sensitive information or implementation details being exposed to the caller which could be used to find exploits in our API

func (Error) Unwrap

func (e Error) Unwrap() error

Unwrap implements the standard library Go unwrapper interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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