uwsgi

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2019 License: MIT Imports: 13 Imported by: 0

README

Package uwsgi provides http.Handler proxying requests to uWSGI listener.

See https://godoc.org/github.com/artyom/uwsgi for details.

Documentation

Overview

Package uwsgi provides http.Handler proxying requests to an uWSGI backend.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler func(context.Context) (net.Conn, error)

Handler is a http.Handler that proxies requests to an uWSGI backend that can be connected to using dialFunc.

Usage example:

network, addr := "unix", "/path/to/uwsgi.socket"
var d net.Dialer
fn := func(ctx context.Context) (net.Conn, error) {
	return d.DialContext(ctx, network, addr)
}
log.Fatal(http.ListenAndServe("localhost:8080", uwsgi.Handler(fn)))

Handler sets some uWSGI-specific variables:

QUERY_STRING
REQUEST_METHOD
CONTENT_TYPE
CONTENT_LENGTH
REQUEST_URI
PATH_INFO
SERVER_PROTOCOL
SERVER_NAME — value from the "Host:" header
HTTPS — only set to "on" if request has https scheme or
	X-Forwarded-Proto: https header
SERVER_PORT — set to "443" if request has https scheme or
	X-Forwarded-Proto: https header
REMOTE_ADDR — either address of connected peer, or leftmost value from
	X-Forwarded-For header if present
REMOTE_PORT — port of connected peer, if can be detected

Note the REMOTE_ADDR variable is populated from X-Forwarded-For if present — if server is exposed directly to the public network you may want to ensure this header is cleared before passing request to this Handler.

func (Handler) ServeHTTP

func (dial Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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