handler

package
v0.0.0-...-05a164b Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GetPointsResponse

type GetPointsResponse struct {
	Points int64 `json:"points"`
}

GetPointsResponse represents the response for getting receipt points

func (*GetPointsResponse) Render

func (resp *GetPointsResponse) Render(_ http.ResponseWriter, _ *http.Request) error

type HealthCheckResponse

type HealthCheckResponse struct {
	Status string `json:"status"`
}

HealthCheckResponse represents the response for the health check endpoint.

func (*HealthCheckResponse) Render

type HealthHandler

type HealthHandler struct{}

func NewHealthHandler

func NewHealthHandler() *HealthHandler

func (*HealthHandler) HealthCheck

func (h *HealthHandler) HealthCheck(w http.ResponseWriter, r *http.Request)

HealthCheck godoc

@Summary		Health check endpoint
@Description	Returns 200 if the server is running
@Tags			health
@Produce		json
@Success		200	{object}	HealthCheckResponse
@Router			/healthz [get]

func (*HealthHandler) RegisterRoutes

func (h *HealthHandler) RegisterRoutes(r chi.Router)

RegisterRoutes registers the health handler routes.

type ProcessReceiptResponse

type ProcessReceiptResponse struct {
	ID uuid.UUID `json:"id"`
}

ProcessReceiptResponse represents the response for processing a receipt

func (*ProcessReceiptResponse) Render

type ReceiptHandler

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

func NewReceiptHandler

func NewReceiptHandler(validate *validator.Validate, repo repository.ReceiptRepository) *ReceiptHandler

func (*ReceiptHandler) GetReceiptPoints

func (h *ReceiptHandler) GetReceiptPoints(w http.ResponseWriter, r *http.Request)

GetReceiptPoints godoc

@Summary		Get the points awarded for a receipt
@Description	Returns the points awarded for the receipt
@Tags			receipts
@Produce		json
@Param			id	path		string	true	"Receipt ID"
@Success		200	{object}	GetPointsResponse
@Failure		404	{string}	string	"No receipt found for that id"
@Router			/receipts/{id}/points [get]

func (*ReceiptHandler) ProcessReceipt

func (h *ReceiptHandler) ProcessReceipt(w http.ResponseWriter, r *http.Request)

ProcessReceipt godoc

@Summary		Submit a receipt for processing
@Description	Submits a receipt for processing
@Tags			receipts
@Accept			json
@Produce		json
@Param			receipt	body		model.Receipt	true	"Receipt"
@Success		200		{object}	ProcessReceiptResponse
@Failure		400		{string}	string	"Invalid receipt"
@Failure		500		{string}	string	"Failed to generate ID"
@Router			/receipts/process [post]

func (*ReceiptHandler) RegisterRoutes

func (h *ReceiptHandler) RegisterRoutes(r chi.Router)

RegisterRoutes registers the receipt handler routes.

Jump to

Keyboard shortcuts

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