Documentation ¶
Index ¶
- Variables
- func RegisterRoutes(h *Handler, router *anor.Router)
- type Handler
- func (h *Handler) CountViewOnProductListingView(w http.ResponseWriter, r *http.Request)
- func (h *Handler) HomeView(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ProductDetailsView(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ProductListingsView(w http.ResponseWriter, r *http.Request)
- func (h *Handler) Render(w http.ResponseWriter, r *http.Request, templatePath string, ...)
- func (h *Handler) SearchListingsView(w http.ResponseWriter, r *http.Request)
- func (h *Handler) SearchQuerySuggestionsView(w http.ResponseWriter, r *http.Request)
- func (h *Handler) TrendingProductsView(w http.ResponseWriter, r *http.Request)
- type HandlerConfig
- type ListingsViewRequest
- type QueryParams
- type SearchListingsViewRequest
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidSearchQueryLength = errors.New("search query must be between 1 and 256 characters") ErrInvalidSearchQueryChars = errors.New("search query contains invalid characters") )
var ErrInvalidHandle = errors.New("invalid handle value")
Functions ¶
func RegisterRoutes ¶
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) 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) Validate ¶
func (l *ListingsViewRequest) Validate() error
type QueryParams ¶
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 (s *SearchListingsViewRequest) Bind(r *http.Request) error
func (*SearchListingsViewRequest) Validate ¶
func (s *SearchListingsViewRequest) Validate() error