httpx

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendPaginatedResponse

func SendPaginatedResponse(c *fiber.Ctx, response PaginatedResponse) error

SendPaginatedResponse sends a paginated response using Fiber context

func SendResponse

func SendResponse(c *fiber.Ctx, response Response) error

SendResponse sends a response using Fiber context

func SendValidationResponse

func SendValidationResponse(c *fiber.Ctx, response ValidationResponse) error

SendValidationResponse sends a validation error response using Fiber context

Types

type PaginatedResponse

type PaginatedResponse struct {
	Response
	Pagination *Pagination `json:"pagination,omitempty"`
}

PaginatedResponse represents a paginated API response

func Paginated

func Paginated(message string, data interface{}, pagination *Pagination) PaginatedResponse

Paginated creates a paginated success response

type Pagination

type Pagination struct {
	Page         int   `json:"page"`
	PerPage      int   `json:"per_page"`
	Total        int64 `json:"total"`
	TotalPages   int   `json:"total_pages"`
	HasNext      bool  `json:"has_next"`
	HasPrevious  bool  `json:"has_previous"`
	NextPage     *int  `json:"next_page,omitempty"`
	PreviousPage *int  `json:"previous_page,omitempty"`
}

Pagination contains pagination metadata

func NewPagination

func NewPagination(page, perPage int, total int64) *Pagination

NewPagination creates pagination metadata

type Response

type Response struct {
	Success   bool        `json:"success"`
	Message   string      `json:"message"`
	Data      interface{} `json:"data,omitempty"`
	Error     string      `json:"error,omitempty"`
	Status    int         `json:"status"`
	Timestamp time.Time   `json:"timestamp"`
}

Response represents a standard API response

func Accepted

func Accepted(message string, data interface{}) Response

Accepted creates a 202 Accepted response

func BadGateway

func BadGateway(message string) Response

BadGateway creates a 502 Bad Gateway response

func BadRequest

func BadRequest(message string, err error) Response

BadRequest creates a 400 Bad Request response

func Conflict

func Conflict(message string, err error) Response

Conflict creates a 409 Conflict response

func Created

func Created(message string, data interface{}) Response

Created creates a 201 Created response

func CustomStatus

func CustomStatus(message string, err error, status int) Response

CustomStatus creates a response with custom status code

func ExpectationFailed

func ExpectationFailed(message string) Response

ExpectationFailed creates a 417 Expectation Failed response

func FailedDependency

func FailedDependency(message string) Response

FailedDependency creates a 424 Failed Dependency response

func Forbidden

func Forbidden(message string) Response

Forbidden creates a 403 Forbidden response

func GatewayTimeout

func GatewayTimeout(message string) Response

GatewayTimeout creates a 504 Gateway Timeout response

func Gone

func Gone(message string) Response

Gone creates a 410 Gone response

func HTTPVersionNotSupported

func HTTPVersionNotSupported(message string) Response

HTTPVersionNotSupported creates a 505 HTTP Version Not Supported response

func InsufficientStorage

func InsufficientStorage(message string) Response

InsufficientStorage creates a 507 Insufficient Storage response

func InternalServerError

func InternalServerError(message string, err error) Response

InternalServerError creates a 500 Internal Server Error response

func LengthRequired

func LengthRequired(message string) Response

LengthRequired creates a 411 Length Required response

func Locked

func Locked(message string) Response

Locked creates a 423 Locked response

func LoopDetected

func LoopDetected(message string) Response

LoopDetected creates a 508 Loop Detected response

func MethodNotAllowed

func MethodNotAllowed(message string) Response

MethodNotAllowed creates a 405 Method Not Allowed response

func NetworkAuthenticationRequired

func NetworkAuthenticationRequired(message string) Response

NetworkAuthenticationRequired creates a 511 Network Authentication Required response

func NoContent

func NoContent(message string) Response

NoContent creates a 204 No Content response

func NotAcceptable

func NotAcceptable(message string) Response

NotAcceptable creates a 406 Not Acceptable response

func NotExtended

func NotExtended(message string) Response

NotExtended creates a 510 Not Extended response

func NotFound

func NotFound(message string) Response

NotFound creates a 404 Not Found response

func NotImplemented

func NotImplemented(message string) Response

NotImplemented creates a 501 Not Implemented response

func NotModified

func NotModified(message string) Response

NotModified creates a 304 Not Modified response

func OK

func OK(message string, data interface{}) Response

OK creates a 200 OK response

func PartialContent

func PartialContent(message string, data interface{}) Response

PartialContent creates a 206 Partial Content response

func PayloadTooLarge

func PayloadTooLarge(message string) Response

PayloadTooLarge creates a 413 Payload Too Large response

func PaymentRequired

func PaymentRequired(message string) Response

PaymentRequired creates a 402 Payment Required response

func PreconditionFailed

func PreconditionFailed(message string) Response

PreconditionFailed creates a 412 Precondition Failed response

func PreconditionRequired

func PreconditionRequired(message string) Response

PreconditionRequired creates a 428 Precondition Required response

func ProxyAuthenticationRequired

func ProxyAuthenticationRequired(message string) Response

ProxyAuthenticationRequired creates a 407 Proxy Authentication Required response

func RangeNotSatisfiable

func RangeNotSatisfiable(message string) Response

RangeNotSatisfiable creates a 416 Range Not Satisfiable response

func RequestHeaderFieldsTooLarge

func RequestHeaderFieldsTooLarge(message string) Response

RequestHeaderFieldsTooLarge creates a 431 Request Header Fields Too Large response

func RequestTimeout

func RequestTimeout(message string) Response

RequestTimeout creates a 408 Request Timeout response

func ServiceUnavailable

func ServiceUnavailable(message string) Response

ServiceUnavailable creates a 503 Service Unavailable response

func Teapot

func Teapot(message string) Response

Teapot creates a 418 I'm a teapot response (RFC 2324)

func TooEarly

func TooEarly(message string) Response

TooEarly creates a 425 Too Early response

func TooManyRequests

func TooManyRequests(message string) Response

TooManyRequests creates a 429 Too Many Requests response

func URITooLong

func URITooLong(message string) Response

URITooLong creates a 414 URI Too Long response

func Unauthorized

func Unauthorized(message string) Response

Unauthorized creates a 401 Unauthorized response

func UnavailableForLegalReasons

func UnavailableForLegalReasons(message string) Response

UnavailableForLegalReasons creates a 451 Unavailable For Legal Reasons response

func UnprocessableEntity

func UnprocessableEntity(message string, err error) Response

UnprocessableEntity creates a 422 Unprocessable Entity response

func UnsupportedMediaType

func UnsupportedMediaType(message string) Response

UnsupportedMediaType creates a 415 Unsupported Media Type response

func UpgradeRequired

func UpgradeRequired(message string) Response

UpgradeRequired creates a 426 Upgrade Required response

func VariantAlsoNegotiates

func VariantAlsoNegotiates(message string) Response

VariantAlsoNegotiates creates a 506 Variant Also Negotiates response

type ValidationError

type ValidationError struct {
	Field   string `json:"field"`
	Message string `json:"message"`
	Value   string `json:"value,omitempty"`
}

ValidationError represents a field validation error

type ValidationResponse

type ValidationResponse struct {
	Response
	Errors []ValidationError `json:"validation_errors,omitempty"`
}

ValidationResponse represents a validation error response

func UnprocessableEntityWithValidation

func UnprocessableEntityWithValidation(message string, errors []ValidationError) ValidationResponse

UnprocessableEntityWithValidation creates a 422 Unprocessable Entity response with validation errors

Jump to

Keyboard shortcuts

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