product

package
v0.0.0-...-3bb7120 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidSearchQueryLength = errors.New("search query must be between 1 and 256 characters")
	ErrInvalidSearchQueryChars  = errors.New("search query contains invalid characters")
)
View Source
var ErrInvalidHandle = errors.New("invalid handle value")

Functions

func RegisterRoutes

func RegisterRoutes(h *Handler, router *anor.Router)

RegisterRoutes sets up the routing for the product-related endpoints. It maps HTTP methods and paths to their respective handler functions.

Types

type Handler

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

func NewHandler

func NewHandler(cfg *HandlerConfig) *Handler

func (*Handler) CountViewOnProductListingView

func (h *Handler) CountViewOnProductListingView(w http.ResponseWriter, r *http.Request)

func (*Handler) HomeView

func (h *Handler) HomeView(w http.ResponseWriter, r *http.Request)

func (*Handler) ProductDetailsView

func (h *Handler) ProductDetailsView(w http.ResponseWriter, r *http.Request)

ProductDetailsView handles the request for the product details page.

func (*Handler) ProductListingsView

func (h *Handler) ProductListingsView(w http.ResponseWriter, r *http.Request)

ProductListingsView handles the request for the product details page.

func (*Handler) Render

func (h *Handler) Render(w http.ResponseWriter, r *http.Request, templatePath string, td templates.TemplateData)

func (*Handler) SearchListingsView

func (h *Handler) SearchListingsView(w http.ResponseWriter, r *http.Request)

SearchListingsView handles the search request. It returns search listings view page

func (*Handler) SearchQuerySuggestionsView

func (h *Handler) SearchQuerySuggestionsView(w http.ResponseWriter, r *http.Request)

SearchQuerySuggestionsView handles search query suggestions requests. It parses the query parameter, fetches product, category and store suggestions, and renders them as a component.

func (*Handler) TrendingProductsView

func (h *Handler) TrendingProductsView(w http.ResponseWriter, r *http.Request)

TrendingProductsView handles requests for trending product suggestions on search dropdown list

type HandlerConfig

type HandlerConfig struct {
	UserService             anor.UserService
	ProductService          anor.ProductService
	CategoryService         anor.CategoryService
	FeatureSelectionService anor.FeaturedSelectionService
	CartService             anor.CartService
	Session                 *session.Manager
	Searcher                search.Searcher
	View                    *html.View
	Logger                  *slog.Logger
	GetHeaderDataFunc       func(ctx context.Context) (header.Base, error)
}

type ListingsViewRequest

type ListingsViewRequest struct {
	CategoryHandle string      // path param
	Query          QueryParams // common listings query params
}

func (*ListingsViewRequest) Bind

func (l *ListingsViewRequest) Bind(r *http.Request) error

func (*ListingsViewRequest) Validate

func (l *ListingsViewRequest) Validate() error

type QueryParams

type QueryParams struct {
	anor.SortParam
	anor.FilterParam
	anor.Paging
}

QueryParams holds parsed and validated query parameters.

func (*QueryParams) Bind

func (q *QueryParams) Bind(r *http.Request) error

Bind parses URL query parameters and populates the QueryParams struct.

func (*QueryParams) Validate

func (q *QueryParams) Validate() error

Validate checks if the parsed query parameters are valid.

type SearchListingsViewRequest

type SearchListingsViewRequest struct {
	Q     string      // search query param
	Query QueryParams // common listings query params
}

func (*SearchListingsViewRequest) Bind

func (*SearchListingsViewRequest) Validate

func (s *SearchListingsViewRequest) Validate() error

Jump to

Keyboard shortcuts

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