endpoints

package
v0.0.0-...-52954b5 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeCreateRequest

func DecodeCreateRequest(ctx context.Context, r *http.Request) (interface{}, error)

func DecodeDeleteRequest

func DecodeDeleteRequest(ctx context.Context, r *http.Request) (interface{}, error)

func DecodeGetByIDRequest

func DecodeGetByIDRequest(ctx context.Context, r *http.Request) (interface{}, error)

func DecodeSearchRequest

func DecodeSearchRequest(ctx context.Context, r *http.Request) (interface{}, error)

func DecodeUpdateRequest

func DecodeUpdateRequest(ctx context.Context, r *http.Request) (interface{}, error)

func EncodeResponse

func EncodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error

func MakeCreateEndpoint

func MakeCreateEndpoint(svc service.Service) endpoint.Endpoint

func MakeDeleteEndpoint

func MakeDeleteEndpoint(svc service.Service) endpoint.Endpoint

func MakeGetByIDEndpoint

func MakeGetByIDEndpoint(svc service.Service) endpoint.Endpoint

func MakeSearchEndpoint

func MakeSearchEndpoint(svc service.Service) endpoint.Endpoint

func MakeUpdateEndpoint

func MakeUpdateEndpoint(svc service.Service) endpoint.Endpoint

func ParseIDFromURL

func ParseIDFromURL(r *http.Request) (uint, error)

Types

type CreateRequest

type CreateRequest struct {
	Data database.ProductIn `json:"data"`
}

type CreateResponse

type CreateResponse struct {
	Message string `json:"message"`
}

type DeleteRequest

type DeleteRequest struct {
	ID uint `json:"id,omitempty"`
}

type DeleteResponse

type DeleteResponse struct {
	Message string `json:"message"`
}

type EndpointSet

type EndpointSet struct {
	GetByIDEndpoint endpoint.Endpoint
	SearchEndpoint  endpoint.Endpoint
	CreateEndpoint  endpoint.Endpoint
	UpdateEndpoint  endpoint.Endpoint
	DeleteEndpoint  endpoint.Endpoint
}

func NewEndpointSet

func NewEndpointSet(svc service.Service) EndpointSet

type GetByIDRequest

type GetByIDRequest struct {
	ID uint `json:"id,omitempty"`
}

type GetByIDResponse

type GetByIDResponse struct {
	Product database.ProductOut `json:"product"`
}

type SearchRequest

type SearchRequest struct {
	Search     string  `json:"search"`
	MinPrice   float32 `json:"minPrice"`
	MaxPrice   float32 `json:"maxPrice"`
	Discount   bool    `json:"discount"`
	CategoryID uint    `json:"CategoryID"`
	SortName   string  `json:"sortName"`
	SortPrice  string  `json:"sortPrice"`
}

type SearchResponse

type SearchResponse struct {
	Products []database.ProductOut `json:"products"`
}

type UpdateRequest

type UpdateRequest struct {
	ID   uint               `json:"id,omitempty"`
	Data database.ProductIn `json:"data"`
}

type UpdateResponse

type UpdateResponse struct {
	Message string `json:"message"`
}

Jump to

Keyboard shortcuts

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