api

package
v0.0.0-...-360b481 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminAuth

func AdminAuth(c *fiber.Ctx) error

func CreateTokenFromUser

func CreateTokenFromUser(user *types.User) string

func ErrorHandler

func ErrorHandler(c *fiber.Ctx, err error) error

func JWTAuthentication

func JWTAuthentication(userStore storeer.UserStore) fiber.Handler

Types

type AuthHandler

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

func NewAuthHandler

func NewAuthHandler(userStore storeer.UserStore) *AuthHandler

func (*AuthHandler) HandleAuthenticate

func (h *AuthHandler) HandleAuthenticate(c *fiber.Ctx) error

A handler should only do:

  • serialization of the incoming request (JSON)
  • do some data fetching from db
  • call some business logic
  • return the data back the user

type AuthParams

type AuthParams struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type AuthResponse

type AuthResponse struct {
	User  *types.User `json:"user"`
	Token string      `json:"token"`
}

type BookRoomParams

type BookRoomParams struct {
	FromDate   time.Time `json:"fromDate"`
	TillDate   time.Time `json:"tillDate"`
	NumPersons int       `json:"numPersons"`
}

type BookingHandler

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

func NewBookingHandler

func NewBookingHandler(store *storeer.Store) *BookingHandler

func (*BookingHandler) HandleCancelBooking

func (h *BookingHandler) HandleCancelBooking(c *fiber.Ctx) error

func (*BookingHandler) HandleGetBooking

func (h *BookingHandler) HandleGetBooking(c *fiber.Ctx) error

func (*BookingHandler) HandleGetBookings

func (h *BookingHandler) HandleGetBookings(c *fiber.Ctx) error

type Error

type Error struct {
	Code int    `json:"code"`
	Err  string `json:"error"`
}

func ErrBadRequest

func ErrBadRequest() Error

func ErrInvalidID

func ErrInvalidID() Error

func ErrNotResourceNotFound

func ErrNotResourceNotFound(res string) Error

func ErrUnAuthorized

func ErrUnAuthorized() Error

func NewError

func NewError(code int, err string) Error

func (Error) Error

func (e Error) Error() string

Error implements the Error interface

type HotelHandler

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

func NewHotelHandler

func NewHotelHandler(store *storeer.Store) *HotelHandler

func (*HotelHandler) HandleGetHotel

func (h *HotelHandler) HandleGetHotel(c *fiber.Ctx) error

func (*HotelHandler) HandleGetHotels

func (h *HotelHandler) HandleGetHotels(c *fiber.Ctx) error

func (*HotelHandler) HandleGetRooms

func (h *HotelHandler) HandleGetRooms(c *fiber.Ctx) error

type HotelQueryParams

type HotelQueryParams struct {
	storeer.Pagination
	Rating int
}

type ResourceResp

type ResourceResp struct {
	Results int `json:"results"`
	Data    any `json:"data"`
	Page    int `json:"page"`
}

type RoomHandler

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

func NewRoomHandler

func NewRoomHandler(store *storeer.Store) *RoomHandler

func (*RoomHandler) HandleBookRoom

func (h *RoomHandler) HandleBookRoom(c *fiber.Ctx) error

func (*RoomHandler) HandleGetRooms

func (h *RoomHandler) HandleGetRooms(c *fiber.Ctx) error

type UserHandler

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

func NewUserHandler

func NewUserHandler(userStore storeer.UserStore) *UserHandler

func (*UserHandler) HandleDeleteUser

func (h *UserHandler) HandleDeleteUser(c *fiber.Ctx) error

func (*UserHandler) HandleGetUser

func (h *UserHandler) HandleGetUser(c *fiber.Ctx) error

func (*UserHandler) HandleGetUsers

func (h *UserHandler) HandleGetUsers(c *fiber.Ctx) error

func (*UserHandler) HandlePostUser

func (h *UserHandler) HandlePostUser(c *fiber.Ctx) error

func (*UserHandler) HandlePutUser

func (h *UserHandler) HandlePutUser(c *fiber.Ctx) error

Jump to

Keyboard shortcuts

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