Help us shape the future of Go! Take the 2026 Go Developer Survey

httputil

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadRequest

func BadRequest(c *app.RequestContext, msg string)

BadRequest sends a 400 response with code=-1.

func Conflict

func Conflict(c *app.RequestContext, msg string)

Conflict sends a 409 response with code=-1.

func InternalError

func InternalError(c *app.RequestContext, msg string)

InternalError sends a 500 response with code=-1. The msg is sent verbatim to the client.

func InternalErrorLog

func InternalErrorLog(ctx context.Context, c *app.RequestContext, op string, err error)

InternalErrorLog logs the underlying err with op context and returns the full error to the client. Per the project convention (AGENTS.md: "错误信息就要全量 给用户显示,不要隐藏任何错误信息") quartet runs in a trusted environment, so surfacing the real error — paths included — beats forcing the user to dig through backend logs.

func MapError

func MapError(c *app.RequestContext, err error, mappings []ErrorMapping)

MapError checks err against a list of mappings and sends the appropriate HTTP response. Whether or not a mapping matches, the full error message is returned to the client (AGENTS.md: errors must be shown in full); a matched mapping only changes the HTTP status code.

func NotFound

func NotFound(c *app.RequestContext, msg string)

NotFound sends a 404 response with code=-1.

Types

type ErrResponse

type ErrResponse struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

ErrResponse is the standard error response envelope. Uses "msg" field to match existing frontend convention.

type ErrorMapping

type ErrorMapping struct {
	Err    error
	Status int
}

ErrorMapping maps sentinel errors to HTTP status codes.

Jump to

Keyboard shortcuts

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