api

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close(ctx context.Context) error

Close represents the graceful shutting down of the http server

func CreateAndInitialiseRecipeAPI

func CreateAndInitialiseRecipeAPI(ctx context.Context, cfg config.Configuration, dataStore store.DataStore, hc *healthcheck.HealthCheck, errorChan chan error)

CreateAndInitialiseRecipeAPI create a new RecipeAPI instance based on the configuration provided and starts the HTTP server.

Types

type RecipeAPI

type RecipeAPI struct {
	Router            *mux.Router
	EnableMongoData   bool
	EnableMongoImport bool
	// contains filtered or unexported fields
}

RecipeAPI contains store and features for managing the recipe

func NewRecipeAPI

func NewRecipeAPI(ctx context.Context, cfg config.Configuration, router *mux.Router, dataStore store.DataStore) *RecipeAPI

NewRecipeAPI create a new Recipe API instance and register the API routes based on the application configuration.

func (*RecipeAPI) AddAllRecipeHandler

func (api *RecipeAPI) AddAllRecipeHandler(w http.ResponseWriter, req *http.Request)

AddAllRecipeHandler - Adds all the recipes from data.go to the mongo database

func (*RecipeAPI) HealthCheck

func (api *RecipeAPI) HealthCheck(w http.ResponseWriter, req *http.Request)

HealthCheck - health check endpoint

func (*RecipeAPI) RecipeHandler

func (api *RecipeAPI) RecipeHandler(w http.ResponseWriter, req *http.Request)

RecipeHandler - get recipe by ID

func (*RecipeAPI) RecipeListHandler

func (api *RecipeAPI) RecipeListHandler(w http.ResponseWriter, req *http.Request)

RecipeListHandler - get all recipes

Jump to

Keyboard shortcuts

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