hh

package module
v0.0.0-...-94c0bac Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadRequest

func BadRequest(message string) error

BadRequest returns an error that will respond with HTTP 400 Bad Request.

func ConvertToInt

func ConvertToInt(value string) (int, error)

func ConvertToPtrUrlURL

func ConvertToPtrUrlURL(value string) (*url.URL, error)

func ConvertToString

func ConvertToString(value string) (string, error)

func ConvertToUuidUUID

func ConvertToUuidUUID(value string) (uuid.UUID, error)

func ExtractFromCookie

func ExtractFromCookie(r *http.Request, name string) (string, bool)

func ExtractFromFile

func ExtractFromFile(r *http.Request, name string) (*multipart.FileHeader, bool)

func ExtractFromForm

func ExtractFromForm(r *http.Request, name string) (string, bool)

func ExtractFromHeader

func ExtractFromHeader(r *http.Request, name string) (string, bool)

func ExtractFromPath

func ExtractFromPath(r *http.Request, name string) (string, bool)

func Forbidden

func Forbidden(message string) error

Forbidden returns an error that will respond with HTTP 403 Forbidden.

func NotFound

func NotFound() error

NotFound returns an error that will respond with HTTP 404 Not Found.

func RespondError

func RespondError(err error, w http.ResponseWriter, r *http.Request)

RespondError writes an error response to the client. If the error is an HttpError, it uses the specified status code and message. Otherwise, it logs the error and returns a generic 500 Internal Server Error with a unique ID.

func Unauthorized

func Unauthorized() error

Unauthorized returns an error that will respond with HTTP 401 Unauthorized.

Types

type BytesValue

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

func Bytes

func Bytes(b []byte) BytesValue

func (BytesValue) ServeHTTP

func (b BytesValue) ServeHTTP(w http.ResponseWriter, r *http.Request)

type HttpError

type HttpError struct {
	Message    string
	StatusCode int
}

HttpError represents an HTTP error with a status code and message.

func (HttpError) Error

func (h HttpError) Error() string

type JSONValue

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

func JSON

func JSON(a any) JSONValue

func (JSONValue) ServeHTTP

func (j JSONValue) ServeHTTP(w http.ResponseWriter, r *http.Request)

type StringValue

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

func String

func String(s string) StringValue

func (StringValue) ServeHTTP

func (s StringValue) ServeHTTP(w http.ResponseWriter, r *http.Request)

Source Files

  • converters.go
  • errors.go
  • extractors.go
  • response.go

Directories

Path Synopsis
cmd
generate command
examples

Jump to

Keyboard shortcuts

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