render

package
v1.0.2-gitspaces-beta Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

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

func PaginationNoTotal(r *http.Request, w http.ResponseWriter, page int, size int, isLastPage bool)

PaginationNoTotal writes the pagination and link headers to the http.Response when total is unknown.

func Reader

func Reader(ctx context.Context, w http.ResponseWriter, code int, reader io.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 StreamSSE

func StreamSSE(
	ctx context.Context,
	w http.ResponseWriter,
	chStop <-chan struct{},
	chEvents <-chan *sse.Event,
	chErr <-chan error,
)

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 UserError

func UserError(ctx context.Context, w http.ResponseWriter, err *usererror.Error)

UserError writes the json-encoded user error.

func Violations

func Violations(w http.ResponseWriter, violations []types.RuleViolations)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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