handlers

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func API

func API(shutdown chan os.Signal, db *sqlx.DB, log *log.Logger, authenticator *auth.Authenticator) http.Handler

API constructs an http.Handler with all application routes defined.

Types

type Account

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

Account holds handlers for dealing with an account.

func (*Account) Token

func (a *Account) Token(ctx context.Context, w http.ResponseWriter, r *http.Request) error

Token generates an authentication token for an account. The client must include a name and password for the request using HTTP Basic Auth. The account will be identified by name and authenticated by the password.

type Check

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

Check provides support for orchestration health checks.

func (*Check) Health

func (c *Check) Health(ctx context.Context, w http.ResponseWriter, r *http.Request) error

Health validates the service is healthy and ready to accept requests.

type StationType

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

func (*StationType) AddStation

func (st *StationType) AddStation(ctx context.Context, w http.ResponseWriter, r *http.Request) error

AddStation creates a new Station for a particular station_type. It looks for a JSON object in the request body. The full model is returned to the caller.

func (*StationType) AdjustStation

func (st *StationType) AdjustStation(ctx context.Context, w http.ResponseWriter, r *http.Request) error

AdjustStation decodes the body of a request to update an existing station. The ID of the station is part of the request URL.

func (*StationType) Create

Create decodes the body of a request to create a new station type. The full station type with generated fields is sent back in the response.

func (*StationType) Delete

Delete removes a single station type identified by an ID in the request URL.

func (*StationType) DeleteStation

func (p *StationType) DeleteStation(ctx context.Context, w http.ResponseWriter, r *http.Request) error

DeleteStation removes a single station identified by an ID in the request URL.

func (*StationType) List

*

  • List StationTypes is a basic HTTP Handler that lists all of the station types in the HydroByte Automated Garden system.
  • A Handler is also know as a "controller" in the MVC pattern. *
  • The parameters must follow the signature defined in the http.HandlerFunc() adapter
  • (https://golang.org/src/net/http/server.go?s=97511:97566#L2034) to convert this method into a HTTP handler type. *
  • Note: If you open localhost:8000 in your browser, you may notice double requests being made. This happens because
  • the browser sends a request in the background for a website favicon. More the reason to use Postman to test!

func (*StationType) ListStations

func (st *StationType) ListStations(ctx context.Context, w http.ResponseWriter, r *http.Request) error

ListStations gets all sales for a particular station type.

func (*StationType) Retrieve

func (st *StationType) Retrieve(ctx context.Context, w http.ResponseWriter, r *http.Request) error

Retrieve finds a station type identified by a station type ID in the request URL.

func (*StationType) RetrieveStation

func (st *StationType) RetrieveStation(ctx context.Context, w http.ResponseWriter, r *http.Request) error

RetrieveStation finds a single station identified by an ID in the request URL.

func (*StationType) Update

Update decodes the body of a request to update an existing station type. The ID of the station type is part of the request URL.

Jump to

Keyboard shortcuts

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