rest

package
v0.0.0-...-f597de0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddPlantRequest

type AddPlantRequest struct {
	Plant
}

AddPlantRequest the parameter to be passed to add a Plant.

type AddPlantResponse

type AddPlantResponse struct {
	ID string `json:"id"`
}

AddPlantResponse the response to an addition of a Plant.

type AuthnController

type AuthnController struct {
	AccountService *account.Service
	JwtService     jwt.Service
}

AuthnController the Authentication Controller.

func (*AuthnController) Signin

func (ac *AuthnController) Signin(w http.ResponseWriter, r *http.Request)

Signin to authenticate user based on a LoginRequest. It returns a LoginResponse.

type JwtMiddleware

type JwtMiddleware struct {
	JwtService jwt.Service
}

JwtMiddleware encapsulates a service checking a JWT token.

func (JwtMiddleware) Check

func (m JwtMiddleware) Check(next http.Handler) http.Handler

Check a JWT token from a "token" Cookie.

type LoginRequest

type LoginRequest struct {
	Username string `json:"username" validate:"required"`
	Password string `json:"password" validate:"required"`
}

LoginRequest the login request parameters.

type LoginResponse

type LoginResponse struct {
	UserID string `json:"userid" validate:"required"`
}

LoginResponse the login request response.

type Plant

type Plant struct {
	ID          string `json:"id"`
	Name        string `json:"name" validate:"required,max=50"`
	PlantedDate string `json:"planted_date" validate:"required,datetime=2006-01-02"`
	Price       string `json:"price" validate:"required,max=20"`
	Reserved    string `json:"reserved" validate:"required"`
}

Plant contains the base info for plant to be created

type PlantController

type PlantController struct {
	PlantService *plant.Service
}

PlantController HTTP requests controller.

func (*PlantController) AddPlant

func (pc *PlantController) AddPlant(w http.ResponseWriter, r *http.Request)

AddPlant HTTP endpoint.

func (*PlantController) GetPlant

func (pc *PlantController) GetPlant(w http.ResponseWriter, r *http.Request)

GetPlant HTTP endpoint.

Jump to

Keyboard shortcuts

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