httpunix

package
v0.27.4 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Overview

Package httpunix provides a HTTP transport (net/http.RoundTripper) that uses Unix domain sockets instead of HTTP.

This is useful for non-browser connections within the same host, as it allows using the file system for credentials of both client and server, and guaranteeing unique names.

The URLs look like this:

http+unix://LOCATION/PATH_ETC

where LOCATION is translated to a file system path with Transport.RegisterLocation, and PATH_ETC follow normal http: scheme conventions.

Index

Constants

View Source
const Scheme = "http+unix"

Scheme is the URL scheme used for HTTP over UNIX domain sockets.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(ctx context.Context, addr string, hndl http.Handler) error

ListenAndServe is the same as http.ListenAndServe, except it can listen on unix domain sockets.

func ListenAndServeSrv

func ListenAndServeSrv(ctx context.Context, addr string, srv *http.Server) error

ListenAndServeSrv is the same as http.ListenAndServe, except it can listen on unix domain sockets.

Types

type Transport

type Transport struct {
	DialTimeout           time.Duration
	RequestTimeout        time.Duration
	ResponseHeaderTimeout time.Duration
	// contains filtered or unexported fields
}

Transport is a http.RoundTripper that connects to Unix domain sockets.

func (*Transport) GetLocation

func (t *Transport) GetLocation(path string) string

GetLocation returns the registered location name for the path, and register if not already registered.

The auto-registered location will be a base64 encoded string of the path.

func (*Transport) RegisterLocation

func (t *Transport) RegisterLocation(loc string, path string)

RegisterLocation registers an URL location and maps it to the given file system path.

Calling RegisterLocation twice for the same location is a programmer error, and causes a panic.

func (*Transport) RoundTrip

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

RoundTrip executes a single HTTP transaction. See net/http.RoundTripper.

Jump to

Keyboard shortcuts

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