request

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package request provides utilities for HTTP request parsing and validation middleware.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthFormData

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

AuthFormData represents common form data structure for login/signup

type ContentType

type ContentType string

ContentType represents the type of content in a request

const (
	// ContentTypeJSON represents JSON content type
	ContentTypeJSON ContentType = "application/json"
	// ContentTypeForm represents form URL-encoded content type
	ContentTypeForm ContentType = "application/x-www-form-urlencoded"
	// ContentTypeMultipart represents multipart form data content type
	ContentTypeMultipart ContentType = "multipart/form-data"
)

type Utils

type Utils struct {
	Sanitizer sanitization.ServiceInterface
}

Utils provides common request processing utilities

func NewUtils

func NewUtils(sanitizer sanitization.ServiceInterface) *Utils

NewUtils creates a new request utils instance

func (*Utils) GetContentType

func (ru *Utils) GetContentType(c echo.Context) ContentType

GetContentType determines the content type of the request

func (*Utils) IsAJAXRequest

func (ru *Utils) IsAJAXRequest(c echo.Context) bool

IsAJAXRequest checks if the request is an AJAX request

func (*Utils) ParseAuthData

func (ru *Utils) ParseAuthData(c echo.Context) (*AuthFormData, error)

ParseAuthData parses authentication form data

func (*Utils) ParseRequestData

func (ru *Utils) ParseRequestData(c echo.Context, target any) error

ParseRequestData parses request data based on content type

func (*Utils) SanitizeEmail

func (ru *Utils) SanitizeEmail(input string) string

SanitizeEmail sanitizes an email input

func (*Utils) SanitizeString

func (ru *Utils) SanitizeString(input string) string

SanitizeString sanitizes a string input using XSS protection

Jump to

Keyboard shortcuts

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