response

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const InternalServerErrorMessage = "internal server error"

Variables

This section is empty.

Functions

func Empty

func Empty(c *gin.Context, response EmptyResponse)

func InternalError

func InternalError(c *gin.Context, err error)

InternalError records the private cause for the request logger and sends a response that does not expose internal details.

func JSON

func JSON[T Payload](c *gin.Context, response JSONResponse[T])

func RecordInternalError

func RecordInternalError(c *gin.Context, err error)

func Text

func Text(c *gin.Context, response TextResponse)

func TwirpInternalError

func TwirpInternalError(c *gin.Context, err error)

TwirpInternalError is InternalError for Twirp routes.

Types

type CreateCacheEntryPayload

type CreateCacheEntryPayload struct {
	SignedUploadURL string `json:"signed_upload_url"`
	// contains filtered or unexported fields
}

type EmptyPayload

type EmptyPayload struct {
	// contains filtered or unexported fields
}

type EmptyResponse

type EmptyResponse interface {
	StatusCode() int
	Headers() map[string]string
}

func AzureCreated

func AzureCreated(requestID string) EmptyResponse

type ErrorPayload

type ErrorPayload struct {
	Error string `json:"error"`
	// contains filtered or unexported fields
}

type FinalizeCacheEntryUploadPayload

type FinalizeCacheEntryUploadPayload struct {
	EntryID string `json:"entry_id"`
	// contains filtered or unexported fields
}

type GetCacheEntryDownloadURLPayload

type GetCacheEntryDownloadURLPayload struct {
	SignedDownloadURL string `json:"signed_download_url"`
	MatchedKey        string `json:"matched_key"`
	// contains filtered or unexported fields
}

type JSONResponse

type JSONResponse[T Payload] interface {
	StatusCode() int
	Body() T
}

func CacheMiss

func CacheMiss() JSONResponse[EmptyPayload]

func CreateCacheEntry

func CreateCacheEntry(uploadURL string) JSONResponse[CreateCacheEntryPayload]

func Error

func Error(status int, message string) JSONResponse[ErrorPayload]

func FinalizeCacheEntryUpload

func FinalizeCacheEntryUpload(entryID string) JSONResponse[FinalizeCacheEntryUploadPayload]

func GetCacheEntryDownloadURL

func GetCacheEntryDownloadURL(downloadURL, matchedKey string) JSONResponse[GetCacheEntryDownloadURLPayload]

func NotImplemented

func NotImplemented() JSONResponse[ErrorPayload]

func TwirpError

func TwirpError(code TwirpCode, message string) JSONResponse[TwirpErrorPayload]

type Payload

type Payload interface {
	// contains filtered or unexported methods
}

type TextResponse

type TextResponse interface {
	StatusCode() int
	Text() string
}

func PlainOK

func PlainOK(body string) TextResponse

func PlainUnavailable

func PlainUnavailable(body string) TextResponse

type TwirpCode

type TwirpCode string
const (
	TwirpMalformed        TwirpCode = "malformed"
	TwirpInvalidArgument  TwirpCode = "invalid_argument"
	TwirpUnauthenticated  TwirpCode = "unauthenticated"
	TwirpPermissionDenied TwirpCode = "permission_denied"
	TwirpNotFound         TwirpCode = "not_found"
	TwirpAlreadyExists    TwirpCode = "already_exists"
	TwirpInternal         TwirpCode = "internal"
	TwirpUnavailable      TwirpCode = "unavailable"
)

func (TwirpCode) HTTPStatus

func (code TwirpCode) HTTPStatus() int

HTTPStatus returns the HTTP status the Twirp spec assigns to code.

type TwirpErrorPayload

type TwirpErrorPayload struct {
	Code TwirpCode `json:"code"`
	Msg  string    `json:"msg"`
}

Jump to

Keyboard shortcuts

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