passthrough

package module
v0.0.0-...-9b75ef9 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2013 License: MIT Imports: 3 Imported by: 0

README

Passthrough

Passes a white list of headers and a response body from a client HTTP request to a ResponseWriter. This can be useful for little proxy services around internal APIs.

func ServeHTTP(w http.ResponseWriter, r *http.Request) {
  res, _ := http.Get("internal/service")
  
  pass := passthrough.New([]string{"Content-Type", "ETag", "Last-Modified"})
  pass.Pass(res, w, 200)
  
  // maybe you just want to pass the headers, but not the body
  pass.PassHeaders(res.Header, w)
}

Barely enough code to extract.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Headers []string
}

func New

func New(headers []string) *Client

func (*Client) Pass

func (c *Client) Pass(res *http.Response, w http.ResponseWriter, status int)

func (*Client) PassHeaders

func (c *Client) PassHeaders(resHeader http.Header, w http.ResponseWriter) http.Header

Jump to

Keyboard shortcuts

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