http

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package http contains the helper functions for writing Spin HTTP components in Go, as well as for sending outbound HTTP requests.

Index

Constants

View Source
const (
	// HeaderBasePath is the application base path.
	HeaderBasePath = "spin-base-path"
	// HeaderComponentRoot is the component route pattern matched, excluding any wildcard indicator.
	HeaderComponentRoot = "spin-component-route"
	// HeaderFullUrl is the full URL of the request, including full host and scheme information.
	HeaderFullUrl = "spin-full-url"
	// HeaderMatchedRoute is the part of the request path that was matched by the route,
	// including the base and wildcard indicator if present.
	HeaderMatchedRoute = "spin-matched-route"
	// HeaderPathInfo is the request path relative to the component route, including any base.
	HeaderPathInfo = "spin-path-info"
	// HeaderRawComponentRoot is the component route pattern matched, as written in the component
	// manifest. It excludes the base but includes the wildcard indicator if present.
	HeaderRawComponentRoot = "spin-raw-component-route"
	// HeaderClientAddr is the client address for the request.
	HeaderClientAddr = "spin-client-addr"
)

Variables

This section is empty.

Functions

func Get

func Get(url string) (*http.Response, error)

Get issues a GET request to the specified URL using the Spin SDK.

func Handle

func Handle(fn func(http.ResponseWriter, *http.Request))

Handle sets the handler function for the http trigger. It must be set in an init() function.

func NewClient

func NewClient() *http.Client

NewClient returns a new HTTP client compatible with the Spin SDK.

func NewTransport

func NewTransport() http.RoundTripper

NewTransport returns an http.RoundTripper backed by the Spin SDK.

func Post

func Post(url string, contentType string, body io.Reader) (*http.Response, error)

Post issues a POST request to the specified URL using the Spin SDK with the given content type and body.

func Send

func Send(req *http.Request) (*http.Response, error)

Send sends an HTTP request using the Spin SDK and returns the response.

Types

type Transport

type Transport struct{}

Transport implements http.RoundTripper using the Spin SDK.

func (*Transport) RoundTrip

func (r *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes a single HTTP transaction using the Spin SDK.

Jump to

Keyboard shortcuts

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