http

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package http provides the JSON-serializable model, mapper, and option decoder for the HTTP layer. It registers itself with the jsonapi registry via init().

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeOptions

func DecodeOptions(raw json.RawMessage) ([]greet.GreetOption, error)

DecodeOptions decodes raw HTTP options into engine GreetOptions.

func FromResult

func FromResult(data greet.LayerData) any

FromResult maps a *greethttp.HTTPResult to *Data.

func Register

func Register(c *jsonapi.Codec)

Register registers the HTTP data mapper and option decoder on the given Codec.

Types

type Data

type Data struct {
	ProtocolVersion string        `json:"protocolVersion"`
	StatusCode      int           `json:"statusCode"`
	Status          string        `json:"status"`
	ResponseHeaders []Header      `json:"responseHeaders,omitempty"`
	Redirects       []RedirectHop `json:"redirects,omitempty"`
}

Data is the JSON-serializable payload for an HTTP layer. The response body is intentionally omitted from the JSON API.

type Header struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

Header is the JSON-serializable form of a single HTTP header.

type Options

type Options struct {
	Target               string   `json:"target,omitempty"`
	Method               string   `json:"method,omitempty"`
	Headers              []Header `json:"headers,omitempty"`
	MaxResponseBodyBytes int64    `json:"maxResponseBodyBytes,omitempty"`
	MaxRedirectFollow    int      `json:"maxRedirectFollow,omitempty"`
}

Options holds JSON-serializable HTTP layer options.

type RedirectHop

type RedirectHop struct {
	URL             string   `json:"url"`
	StatusCode      int      `json:"statusCode"`
	Method          string   `json:"method"`
	ResponseHeaders []Header `json:"responseHeaders,omitempty"`
}

RedirectHop is a single redirect that was followed.

Jump to

Keyboard shortcuts

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