web

package
v1.1.28-test Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ContainerItemNotFoundErr error = errors.New("no matching item found")
)

Functions

func CORSMiddleware

func CORSMiddleware(next http.Handler) http.Handler

CORSMiddleware adds CORS headers to all responses and handles OPTIONS preflight requests

func DoJSONRequestWithBody

func DoJSONRequestWithBody[TBody any](client *http.Client, method string, url string, body TBody, token string) error

func DoJSONRequestWithBodyAndResult

func DoJSONRequestWithBodyAndResult[TBody any, TResult any](client *http.Client, method string, url string, body TBody, token string) (TResult, error)

func DoJSONRequestWithResult

func DoJSONRequestWithResult[TResult any](client *http.Client, method string, url string, token string) (TResult, error)

func DoRequest

func DoRequest(httpClient *http.Client, request *http.Request) (*http.Response, error)

func GetBearerToken

func GetBearerToken(r *http.Request) (string, error)

func GetItem

func GetItem[DesiredType any, T any](c Container[T]) (DesiredType, error)

func GetRepository

func GetRepository[TRepo database.Repository](c RepositoryContainer) (TRepo, error)

func MustGetRepository

func MustGetRepository[TRepo database.Repository](c RepositoryContainer) TRepo

func ParseJsonRequestBody

func ParseJsonRequestBody[T any](request *http.Request) (T, error)

func ParseJsonResponseBody

func ParseJsonResponseBody[T any](response *http.Response) (T, error)

func ReturnError

func ReturnError(w http.ResponseWriter, err error) (int, error)

func ReturnResponse

func ReturnResponse(w http.ResponseWriter, data any) (int, error)

func ReturnResponseWithCode

func ReturnResponseWithCode(w http.ResponseWriter, data any, code int) (int, error)

func Token

func Token(request *http.Request) string

func ValidateToken

func ValidateToken(token string) error

Types

type AuthorizationHeaders

type AuthorizationHeaders map[string]string

AuthorizationHeaders type

func GetAuthorizationHeaders

func GetAuthorizationHeaders(request *http.Request) AuthorizationHeaders

type Container

type Container[T any] interface {
	Append(key string, item T)
	List() []T
	Get(key string) T
	Delete(key string)
}

func NewContainer

func NewContainer[T any]() Container[T]

type RepositoryContainer

type RepositoryContainer interface {
	Container[database.Repository]
}

func NewRepositoryContainer

func NewRepositoryContainer() RepositoryContainer

Directories

Path Synopsis
Package search holds the column metadata and sort helpers shared by services that expose paged, sortable search endpoints.
Package search holds the column metadata and sort helpers shared by services that expose paged, sortable search endpoints.

Jump to

Keyboard shortcuts

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