Documentation
¶
Index ¶
- func BadRequest(ctx context.Context, w http.ResponseWriter)
- func BadRequestf(ctx context.Context, w http.ResponseWriter, format string, args ...interface{})
- func DeleteSuccessful(w http.ResponseWriter)
- func Forbidden(ctx context.Context, w http.ResponseWriter)
- func InternalError(ctx context.Context, w http.ResponseWriter)
- func JSON(w http.ResponseWriter, code int, v interface{})
- func JSONArrayDynamic[T comparable](ctx context.Context, w http.ResponseWriter, stream types.Stream[T])
- func NoCache(w http.ResponseWriter)
- func NotFound(ctx context.Context, w http.ResponseWriter)
- func Pagination(r *http.Request, w http.ResponseWriter, page, size, total int)
- func PaginationLimit(_ *http.Request, w http.ResponseWriter, total int)
- func PaginationNoTotal(r *http.Request, w http.ResponseWriter, page int, size int, isLastPage bool)
- func Reader(ctx context.Context, w http.ResponseWriter, code int, reader io.Reader)
- func StreamSSE(ctx context.Context, w http.ResponseWriter, chStop <-chan struct{}, ...)
- func TranslatedUserError(ctx context.Context, w http.ResponseWriter, err error)
- func Unauthorized(ctx context.Context, w http.ResponseWriter)
- func Unprocessable(w http.ResponseWriter, v any)
- func UserError(ctx context.Context, w http.ResponseWriter, err *usererror.Error)
- func Violations(w http.ResponseWriter, violations []types.RuleViolations)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BadRequest ¶
func BadRequest(ctx context.Context, w http.ResponseWriter)
BadRequest writes the json-encoded message for a bad request error.
func BadRequestf ¶
func BadRequestf(ctx context.Context, w http.ResponseWriter, format string, args ...interface{})
BadRequestf writes the json-encoded message with a bad request status code.
func DeleteSuccessful ¶
func DeleteSuccessful(w http.ResponseWriter)
DeleteSuccessful writes the header for a successful delete.
func Forbidden ¶
func Forbidden(ctx context.Context, w http.ResponseWriter)
Forbidden writes the json-encoded message for a forbidden error.
func InternalError ¶
func InternalError(ctx context.Context, w http.ResponseWriter)
InternalError writes the json-encoded message for an internal error.
func JSON ¶
func JSON(w http.ResponseWriter, code int, v interface{})
JSON writes the json-encoded value to the response with the provides status.
func JSONArrayDynamic ¶
func JSONArrayDynamic[T comparable](ctx context.Context, w http.ResponseWriter, stream types.Stream[T])
JSONArrayDynamic outputs an JSON array whose elements are streamed from a channel. Due to the dynamic nature (unknown number of elements) the function will use chunked transfer encoding for large files.
func NoCache ¶
func NoCache(w http.ResponseWriter)
NoCache writes the required headers to communicate to the client no caching shall be done.
func NotFound ¶
func NotFound(ctx context.Context, w http.ResponseWriter)
NotFound writes the json-encoded message for a not found error.
func Pagination ¶
func Pagination(r *http.Request, w http.ResponseWriter, page, size, total int)
Pagination writes the pagination and link headers to the http.Response.
func PaginationLimit ¶
func PaginationLimit(_ *http.Request, w http.ResponseWriter, total int)
PaginationLimit writes the x-total header.
func PaginationNoTotal ¶
PaginationNoTotal writes the pagination and link headers to the http.Response when total is unknown.
func Reader ¶
Reader reads the content from the provided reader and writes it as is to the response body. NOTE: If no content-type header is added beforehand, the content-type will be deduced automatically by `http.DetectContentType` (https://pkg.go.dev/net/http#DetectContentType).
func TranslatedUserError ¶
func TranslatedUserError(ctx context.Context, w http.ResponseWriter, err error)
TranslatedUserError writes the translated user error of the provided error.
func Unauthorized ¶
func Unauthorized(ctx context.Context, w http.ResponseWriter)
Unauthorized writes the json-encoded message for an unauthorized error.
func Unprocessable ¶
func Unprocessable(w http.ResponseWriter, v any)
func Violations ¶
func Violations(w http.ResponseWriter, violations []types.RuleViolations)
Types ¶
This section is empty.