mhttp

package
Version: v0.0.0-...-c20f884 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package mhttp extends the standard package with extra functionality which is commonly useful

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddXForwardedFor

func AddXForwardedFor(r *http.Request, ipStr string)

AddXForwardedFor populates the X-Forwarded-For header on the Request to convey that the request is being proxied for IP.

If the IP is invalid, loopback, or otherwise part of a reserved range, this does nothing.

func ReverseProxy

func ReverseProxy(u *url.URL) *httputil.ReverseProxy

ReverseProxy returns an httputil.ReverseProxy which will send requests to the given URL and copy their responses back without modification.

Only the Scheme and Host of the given URL are used.

Any http.ResponseWriters passed into the ServeHTTP call of the returned instance should not be modified afterwards.

Types

type Server

type Server struct {
	*http.Server
	// contains filtered or unexported fields
}

Server is returned by WithListeningServer and simply wraps an *http.Server.

func InstListeningServer

func InstListeningServer(cmp *mcmp.Component, h http.Handler) *Server

InstListeningServer returns a *Server which will be initialized and have ListenAndServe called on it (asynchronously) when the Init event is triggered on the Component. The Server will have Shutdown called on it when the Shutdown event is triggered on the Component.

This function automatically handles setting up configuration parameters via mcfg. The default listen address is ":0".

Source Files

Jump to

Keyboard shortcuts

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