api

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthorizeError added in v0.5.6

func AuthorizeError(ctx context.Context, code int, message string, w http.ResponseWriter) (bool, *http.Request)

func CommitTx

func CommitTx(ctx context.Context, responseCode int) (code int, body []byte, err error)

func ErrorResponse

func ErrorResponse(ctx context.Context, code int, message string) (int, []byte, error)

func ExtractJSON

func ExtractJSON[ReqData jt.Defaulter[ReqData]](r *http.Request) (reqData ReqData, l *slog.Logger, ctx context.Context, code int, body []byte, err error)

func RespondJSON

func RespondJSON(ctx context.Context, code int, data any) (int, []byte, error)

Types

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type Metadata

type Metadata struct {
	RequestUUID uuid.UUID `json:"requestUUID"`
}

type Response

type Response struct {
	Data     any      `json:"data,omitempty"`
	Metadata Metadata `json:"metadata"`
}

func NewAPIError

func NewAPIError(ctx context.Context, code int, message string) Response

Jump to

Keyboard shortcuts

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