Back to godoc.org

Package api

v1.0.12
Latest Go to latest

The highest tagged major version is v2.

Published: Jul 6, 2020 | License: Apache-2.0 | Module: github.com/square/spincycle

Overview

Package api provides controllers for each api endpoint. Controllers are "dumb wiring"; there is little to no application logic in this package. Controllers call and coordinate other packages to satisfy the api endpoint. Authentication and authorization happen in controllers.

Index

Constants

const (
	API_ROOT = "/api/v1/"
)

Variables

var (
	// Error when Request Manager is shutting down and not starting new requests
	ErrShuttingDown = errors.New("Request Manager is shutting down - no new requests are being started")
)

type API

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

API provides controllers for endpoints it registers with a router. It satisfies the http.HandlerFunc interface.

func NewAPI

func NewAPI(appCtx app.Context) *API

NewAPI creates a new API struct. It initializes an echo web server within the struct, and registers all of the API's routes with it.

func (*API) Router

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

func (*API) Run

func (api *API) Run() error

Run makes the API listen on the configured address.

func (*API) ServeHTTP

func (api *API) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP makes the API implement the http.HandlerFunc interface.

func (*API) Stop

func (api *API) Stop() error

Stop stops the API when it's running. When Stop is called, Run returns immediately. Make sure to wait for Stop to return.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier