rest

package
v0.0.0-...-7a9e484 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package rest provides a controller for handling API requests.

Package rest provides a controller for handling API requests.

Package rest provides a controller for handling API requests.

Package rest provides a controller for handling API requests.

Package rest provides a controller for handling API requests.

Package rest provides a controller for handling API requests.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidNumberFormat = errors.New("the provided number format is not valid")
	ErrProcessingFailed    = errors.New("failed processing the request")
	ErrInvalidFormData     = errors.New("the provided form data is not valid")
	ErrForbiddenAction     = errors.New("no permission for performing the action")
)

Functions

This section is empty.

Types

type Controller

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

Controller provides HTTP handling methods for executing any business logic. It is the default gateway for any HTTP-related interfaces. Its main purpose is to deal with incoming REST API requests.

func NewController

func NewController(r *restaurant.Service, d *dish.Service, u *user.Service, o *offer.Service, odr *order.Service) *Controller

NewController creates a new Controller instances and returns a reference to it. Each service has to be completely initialized so they're ready to use.

func (*Controller) ActiveOffers

func (c *Controller) ActiveOffers() http.HandlerFunc

ActiveOffers is responsible for retrieving all active offers.

func (*Controller) AllOrders

func (c *Controller) AllOrders() http.HandlerFunc

AllOrders is responsible for retrieving all user orders for a given offer.

func (*Controller) CancelOffer

func (c *Controller) CancelOffer(session session.Manager) http.HandlerFunc

CancelOffer is responsible for any offer cancellations. All user-related data needs to be provided by the accepted session manager.

func (*Controller) ConfirmMailAddr

func (c *Controller) ConfirmMailAddr() http.HandlerFunc

ConfirmMailAddr is responsible for confirming a user's mail address who has just registered. The corresponding confirmation mail has been sent by RegisterUser.

func (*Controller) CreateOffer

func (c *Controller) CreateOffer(session session.Manager) http.HandlerFunc

CreateOffer is responsible for creating a new offer. All user-related data needs to be provided by the accepted session manager.

func (*Controller) GetCharacteristics

func (c *Controller) GetCharacteristics() http.HandlerFunc

GetCharacteristics is responsible for retrieving a dish's characteristics.

func (*Controller) GetOffer

func (c *Controller) GetOffer() http.HandlerFunc

GetOffers is responsible for retrieving all required data for a given offer.

func (*Controller) GetOrder

func (c *Controller) GetOrder(session session.Manager) http.HandlerFunc

GetOrder is responsible for retrieving a given order. All user-related data needs to be provided by the accepted session manager.

func (*Controller) GetUser

func (c *Controller) GetUser() http.HandlerFunc

GetUser is responsible for retrieving all data for a given user.

func (*Controller) IsAuthenticated

func (c *Controller) IsAuthenticated(session session.Manager) http.HandlerFunc

IsAuthenticated is responsible for determining whether a user is logged in or not. All user-related data needs to be provided by the accepted session manager.

func (*Controller) Login

func (c *Controller) Login(session session.Manager) http.HandlerFunc

Login is responsible for logging in an existing user. The provided session manager will create a new user session if the login has been successful.

func (*Controller) Logout

func (c *Controller) Logout(session session.Manager) http.HandlerFunc

Logout is responsible for quitting a user session. The provided session manager will remove any data associated with the particular session.

func (*Controller) MarkOrderAsPaid

func (c *Controller) MarkOrderAsPaid(session session.Manager) http.HandlerFunc

MarkOrderAsPaid is responsible for setting the IsPaid property of a given order to true. All user-related data needs to be provided by the accepted session manager.

func (*Controller) OldOffers

func (c *Controller) OldOffers() http.HandlerFunc

OldOffers is responsible for retrieving all expired offers.

func (*Controller) RegisterUser

func (c *Controller) RegisterUser() http.HandlerFunc

RegisterUser is responsible for triggering an user registration.

func (*Controller) RestaurantInfo

func (c *Controller) RestaurantInfo() http.HandlerFunc

RestaurantInfo is responsible for retrieving information for a given restaurant.

func (*Controller) RestaurantMenu

func (c *Controller) RestaurantMenu() http.HandlerFunc

RestaurantMenu is responsible for retrieving a given restaurant's menu including all menu sections (categories) and all dishes. The dishes don't contain all available characteristics. They can be retrieved using the GetCharacteristics method.

func (*Controller) SetPaypalMailAddr

func (c *Controller) SetPaypalMailAddr(session session.Manager) http.HandlerFunc

SetPaypalMailAddr is responsible for setting the PaypayMailAddr property of a given user.

func (*Controller) SetReadyAt

func (c *Controller) SetReadyAt() http.HandlerFunc

SetReadyAt is responsible for setting the IsReady property of a given offer. All user-related data needs to be provided by the accepted session manager.

func (*Controller) Status

func (c *Controller) Status() http.HandlerFunc

Status simply returns `true` indicating that the server is up and running.

func (*Controller) UpdateOrder

func (c *Controller) UpdateOrder(session session.Manager) http.HandlerFunc

UpdateOrder is responsible for setting all properties (including positions) of an given order. All user-related data needs to be provided by the accepted session manager.

Jump to

Keyboard shortcuts

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