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

api

package
v1.21.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// StatusClientClosedRequest is the status code for when a client request cancellation of a http request
	StatusClientClosedRequest = 499
)

Variables

This section is empty.

Functions

func RespondError

func RespondError(logger log.Logger, w http.ResponseWriter, errorType v1.ErrorType, msg string, statusCode int)

RespondError writes error in Prometheus response format using provided error type and message.

func RespondFromGRPCError

func RespondFromGRPCError(logger log.Logger, w http.ResponseWriter, err error)

RespondFromGRPCError writes gRPC error in Prometheus response format. If error is not a valid gRPC error, use server_error instead.

Types

type Response

type Response struct {
	Status    string       `json:"status"`
	Data      any          `json:"data,omitempty"`
	ErrorType v1.ErrorType `json:"errorType,omitempty"`
	Error     string       `json:"error,omitempty"`
	Warnings  []string     `json:"warnings,omitempty"`
	Infos     []string     `json:"infos,omitempty"`
}

Response defines the Prometheus response format.

Jump to

Keyboard shortcuts

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