response

package
v0.1.23 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorJSON

func ErrorJSON(w http.ResponseWriter, status int, code ErrorCode, message string)

func JSON

func JSON(w http.ResponseWriter, status int, v any)

func WriteError

func WriteError(w http.ResponseWriter, spec ErrorSpec, message string)

Types

type Error

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

type ErrorCode

type ErrorCode string
const (
	CodeUnauthorized ErrorCode = "unauthorized"
	CodeForbidden    ErrorCode = "forbidden"

	CodeInvalidRequest ErrorCode = "invalid_request"
	CodeNotFound       ErrorCode = "not_found"
	CodeRateLimited    ErrorCode = "rate_limited"

	CodeInternalError ErrorCode = "internal_error"
)

type ErrorResponse

type ErrorResponse struct {
	Error Error `json:"error"`
}

type ErrorSpec

type ErrorSpec struct {
	Status int
	Code   ErrorCode
}

type User

type User struct {
	ID        string       `json:"id"`
	Email     string       `json:"email"`
	Username  string       `json:"username"`
	Disabled  bool         `json:"disabled"`
	CreatedAt time.Time    `json:"created_at"`
	Roles     []roles.Role `json:"roles"`
}

func UserWithRoles

func UserWithRoles(u domain.User, roles []roles.Role) User

Jump to

Keyboard shortcuts

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