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

web

package
v0.65.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package web holds the HTTP plumbing shared by the JSON APIs in this repo: the error wire shape, build identity, and the version handler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VersionHandler

func VersionHandler(service string) http.HandlerFunc

VersionHandler serves {service, ...Build} so a caller can confirm which build is running.

Types

type BadRequestError

type BadRequestError struct {
	Msg string
	Err error
}

BadRequestError marks a body the transport could not read (400), as distinct from a well-formed request that failed validation (422).

func (*BadRequestError) Error

func (e *BadRequestError) Error() string

func (*BadRequestError) Unwrap

func (e *BadRequestError) Unwrap() error

type Build

type Build struct {
	Revision string `json:"revision"`
	Modified bool   `json:"modified"`
	Time     string `json:"time"`
	Go       string `json:"go"`
}

Build is the VCS identity Go stamps into a binary. Revision is empty under -buildvcs=false, which reads as an unknown build.

func ReadBuild

func ReadBuild() Build

ReadBuild reads the build identity from the running binary.

type ErrorBody

type ErrorBody struct {
	Kind    string            `` /* 182-byte string literal not displayed */
	Message string            `json:"message"`
	Fields  map[string]string `` /* 131-byte string literal not displayed */
}

ErrorBody is the error wire shape: {kind, message}, with per-field detail on validation failures.

Directories

Path Synopsis
Package extractors decodes and validates request input: Body decodes into a typed struct and runs its Validate method when it has one.
Package extractors decodes and validates request input: Body decodes into a typed struct and runs its Validate method when it has one.
Package mid holds the errchain error middleware shared by the JSON APIs.
Package mid holds the errchain error middleware shared by the JSON APIs.

Jump to

Keyboard shortcuts

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