handlers

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2022 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractJWT added in v0.0.17

func ExtractJWT(authToken string) (int, int, error)

ExtractJWT retrieves the token and user ID from the JWT

Types

type AuthMiddleware added in v0.0.17

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

Middleware -

func NewAuthMiddleware added in v0.0.17

func NewAuthMiddleware(con data.Connection, l hclog.Logger) *AuthMiddleware

NewMiddleware -

func (*AuthMiddleware) IsAuthorized added in v0.0.17

func (c *AuthMiddleware) IsAuthorized(next func(userID int, w http.ResponseWriter, r *http.Request)) http.Handler

IsAuthorized

func (*AuthMiddleware) VerifyJWT added in v0.0.17

func (c *AuthMiddleware) VerifyJWT(authToken string) (int, error)

type AuthResponse added in v0.0.12

type AuthResponse struct {
	UserID   int    `json:"user_id,omitempty`
	Username string `json:"username,omitempty`
	Token    string `json:"token,omitempty"`
}

AuthResponse -

type AuthStruct added in v0.0.12

type AuthStruct struct {
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

AuthStruct -

type Coffee added in v0.0.6

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

Coffee -

func NewCoffee added in v0.0.6

func NewCoffee(con data.Connection, l hclog.Logger) *Coffee

NewCoffee

func (*Coffee) CreateCoffee added in v0.0.14

func (c *Coffee) CreateCoffee(_ int, rw http.ResponseWriter, r *http.Request)

CreateCoffee creates a new coffee

func (*Coffee) ServeHTTP added in v0.0.6

func (c *Coffee) ServeHTTP(rw http.ResponseWriter, r *http.Request)

type Health

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

Health is a HTTP Handler for health checking

func NewHealth

func NewHealth(t *telemetry.Telemetry, l hclog.Logger, db data.Connection) *Health

NewHealth creates a new Health handler

func (*Health) Liveness added in v0.0.22

func (h *Health) Liveness(rw http.ResponseWriter, r *http.Request)

Liveness endpoint for health checks indicates server has started

func (*Health) Readiness added in v0.0.22

func (h *Health) Readiness(rw http.ResponseWriter, r *http.Request)

Readiness endpoint for health checks indicates server is ready to serve traffic

func (*Health) ServeHTTP added in v0.0.6

func (h *Health) ServeHTTP(rw http.ResponseWriter, r *http.Request)

ServeHTTP implements the handler interface Deprecated: Use Liveness and Readiness handlers instead

type Ingredients added in v0.0.8

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

Ingredients -

func NewIngredients added in v0.0.8

func NewIngredients(con data.Connection, l hclog.Logger) *Ingredients

NewIngredients -

func (*Ingredients) CreateCoffeeIngredient added in v0.0.14

func (c *Ingredients) CreateCoffeeIngredient(_ int, rw http.ResponseWriter, r *http.Request)

CreateCoffeeIngredient creates a new coffee ingredient

func (*Ingredients) ServeHTTP added in v0.0.8

func (c *Ingredients) ServeHTTP(rw http.ResponseWriter, r *http.Request)

type Order added in v0.0.12

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

Order -

func NewOrder added in v0.0.12

func NewOrder(con data.Connection, l hclog.Logger) *Order

NewOrder -

func (*Order) CreateOrder added in v0.0.12

func (c *Order) CreateOrder(userID int, rw http.ResponseWriter, r *http.Request)

CreateOrder creates a new order

func (*Order) DeleteOrder added in v0.0.12

func (c *Order) DeleteOrder(userID int, rw http.ResponseWriter, r *http.Request)

DeleteOrder deletes a user order

func (*Order) GetUserOrder added in v0.0.12

func (c *Order) GetUserOrder(userID int, rw http.ResponseWriter, r *http.Request)

GetUserOrder gets a specific user order

func (*Order) GetUserOrders added in v0.0.12

func (c *Order) GetUserOrders(userID int, rw http.ResponseWriter, r *http.Request)

GetUserOrders gets all user orders for a specific user

func (*Order) ServeHTTP added in v0.0.12

func (c *Order) ServeHTTP(userID int, rw http.ResponseWriter, r *http.Request)

func (*Order) UpdateOrder added in v0.0.12

func (c *Order) UpdateOrder(userID int, rw http.ResponseWriter, r *http.Request)

UpdateOrder updates an order

type User added in v0.0.12

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

User -

func NewUser added in v0.0.12

func NewUser(con data.Connection, l hclog.Logger) *User

NewUser -

func (*User) ServeHTTP added in v0.0.12

func (c *User) ServeHTTP(rw http.ResponseWriter, r *http.Request)

func (*User) SignIn added in v0.0.12

func (c *User) SignIn(rw http.ResponseWriter, r *http.Request)

SignIn signs in a user and returns a JWT token

func (*User) SignOut added in v0.0.17

func (c *User) SignOut(rw http.ResponseWriter, r *http.Request)

SignOut signs out a user and invalidates a JWT token

func (*User) SignUp added in v0.0.12

func (c *User) SignUp(rw http.ResponseWriter, r *http.Request)

SignUp registers a new user and returns a JWT token only restriction is username must be unique

Jump to

Keyboard shortcuts

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