goprox

package module
v0.0.0-...-31a2f47 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2016 License: GPL-3.0 Imports: 5 Imported by: 0

README

goprox godoc Travis CI Coverage

A simple reverse proxy middleware written in golang

Example

The simplest way to use GoProx is to use it as the sole handler for all requests.

package main

import (
	"os"
	"log"
	"net/http"
	"net/url"

	"github.com/damnpoet/goprox"
)

func main() {
	mux := http.NewServeMux()

	u, err := url.Parse(spadeURL)
	if err != nil {
		log.Fatal(err)
	}

	proxy := goprox.New(u, goprox.Options{})
	handler := proxy.Handler(mux)

	log.Fatal(http.ListenAndServe(":8080", handler))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Destination is the URL for the host where requests will be sent to
	Destination string
	// Path will restrict the proxy requests to the specified path.
	Path string
	// Debugging flag adds additional output to debug server side issues
	Debug bool
}

Options is a configuration container to setup the GoProx middleware.

type Proxy

type Proxy struct {
	// contains filtered or unexported fields
}

Proxy represents the reverse proxy

func New

func New(dest *url.URL, options Options) *Proxy

New creates a new instance of Proxy

func (*Proxy) Handler

func (p *Proxy) Handler(h http.Handler) http.Handler

Handler apply the Proxy specification on the request

Jump to

Keyboard shortcuts

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