api

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HelloHandler

func HelloHandler() http.HandlerFunc

HelloHandler returns function containing a simple hello world example of an api handler

func ReadJSONBody added in v0.3.0

func ReadJSONBody(ctx context.Context, body io.ReadCloser, v interface{}, w http.ResponseWriter, data log.Data) error

ReadJSONBody reads the bytes from the provided body, and marshals it to the provided model interface.

func WriteJSONBody added in v0.3.0

func WriteJSONBody(ctx context.Context, v interface{}, w http.ResponseWriter, data log.Data) error

WriteJSONBody marshals the provided interface into json, and writes it to the response body.

Types

type API

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

API provides a struct to wrap the api around

func Setup

func Setup(ctx context.Context, cfg *config.Config, router *mux.Router, dataStore store.DataStore, permissions AuthHandler) *API

Setup function sets up the api and returns an api

type AuthHandler added in v0.2.0

type AuthHandler interface {
	Require(required auth.Permissions, handler http.HandlerFunc) http.HandlerFunc
}

AuthHandler interface for adding auth to endpoints

type MongoServer added in v0.2.0

type MongoServer interface {
	Close(ctx context.Context) error
	Checker(ctx context.Context, state *healthcheck.CheckState) (err error)
	GetTopic(id string) (topic *models.TopicResponse, err error)
}

MongoServer defines the required methods from MongoDB

Jump to

Keyboard shortcuts

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