serviceapi

package
v0.1.0-rc.35 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package serviceapi provides HTTP helpers for the private service APIs.

Index

Constants

View Source
const MaximumRequestBytes = 64 << 10

Variables

This section is empty.

Functions

func DecodeJSON

func DecodeJSON(response http.ResponseWriter, request *http.Request, destination any) bool

func Nonnegative

func Nonnegative(value int64) (uint64, bool)

func Positive

func Positive(value int64) (uint64, bool)

func ValidIdentifiers

func ValidIdentifiers(values ...string) bool

func WriteJSON

func WriteJSON(response http.ResponseWriter, status int, value any)

func WriteProblem

func WriteProblem(response http.ResponseWriter, status int, problemType, detail string)

func WriteProblemError

func WriteProblemError(response http.ResponseWriter, problem *ProblemError)

Types

type BearerSecrets

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

BearerSecrets authenticates a current service secret and an optional previous secret retained only for a rolling rotation.

func NewBearerSecrets

func NewBearerSecrets(current, previous string) (BearerSecrets, error)

func (BearerSecrets) Authenticate

func (s BearerSecrets) Authenticate(header http.Header) bool

func (BearerSecrets) Matches

func (s BearerSecrets) Matches(candidate string) bool

func (BearerSecrets) Valid

func (s BearerSecrets) Valid() bool

type ProblemError

type ProblemError struct {
	Status int
	Type   string
	Title  string
	Detail string
}

ProblemError describes a private service API failure without HTTP client or server details.

func NewProblemError

func NewProblemError(status int, problemType, detail string) *ProblemError

func (*ProblemError) Error

func (e *ProblemError) Error() string

Jump to

Keyboard shortcuts

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