response

package
v0.1.25 Latest Latest
Warning

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

Go to latest
Published: Jun 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 Organization added in v0.1.24

type Organization struct {
	ID   string                  `json:"id"`
	Name string                  `json:"name"`
	Role domain.OrganizationRole `json:"role"`
}

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"`
	Organization *Organization `json:"organization,omitempty"`
}

func UserWithRoles

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

func UserWithRolesAndOrganization added in v0.1.24

func UserWithRolesAndOrganization(u domain.User, roles []roles.Role, org domain.Organization, orgRole domain.OrganizationRole) User

Jump to

Keyboard shortcuts

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