Documentation
¶
Index ¶
- Variables
- func DoJSONRequestWithBody[TBody any](client *http.Client, method string, url string, body TBody, token string) error
- func DoJSONRequestWithBodyAndResult[TBody any, TResult any](client *http.Client, method string, url string, body TBody, token string) (TResult, error)
- func DoJSONRequestWithResult[TResult any](client *http.Client, method string, url string, token string) (TResult, error)
- func DoRequest(httpClient *http.Client, request *http.Request) (*http.Response, error)
- func GetBearerToken(r *http.Request) (string, error)
- func GetItem[DesiredType any, T any](c Container[T]) (DesiredType, error)
- func GetRepository[TRepo database.Repository](c RepositoryContainer) (TRepo, error)
- func MustGetRepository[TRepo database.Repository](c RepositoryContainer) TRepo
- func ParseJsonRequestBody[T any](request *http.Request) (T, error)
- func ParseJsonResponseBody[T any](response *http.Response) (T, error)
- func ReturnError(w http.ResponseWriter, err error) (int, error)
- func ReturnResponse(w http.ResponseWriter, data any) (int, error)
- func ReturnResponseWithCode(w http.ResponseWriter, data any, code int) (int, error)
- func Token(request *http.Request) string
- func ValidateToken(token string) error
- type AuthorizationHeaders
- type Container
- type RepositoryContainer
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ContainerItemNotFoundErr error = errors.New("no matching item found")
)
Functions ¶
func DoJSONRequestWithBody ¶
func DoJSONRequestWithResult ¶
func GetRepository ¶
func GetRepository[TRepo database.Repository](c RepositoryContainer) (TRepo, error)
func MustGetRepository ¶
func MustGetRepository[TRepo database.Repository](c RepositoryContainer) TRepo
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 ValidateToken ¶
Types ¶
type AuthorizationHeaders ¶
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 ¶
type RepositoryContainer ¶
type RepositoryContainer interface {
Container[database.Repository]
}
func NewRepositoryContainer ¶
func NewRepositoryContainer() RepositoryContainer
Click to show internal directories.
Click to hide internal directories.