Skip to content

Latest commit

 

History

History
33 lines (25 loc) · 1.29 KB

File metadata and controls

33 lines (25 loc) · 1.29 KB

build coverage goreport Docs

httpproxy

HTTP(S) and WebSocket forward proxy.

Supports user authentication, ContextDialer selection per proxy request and custom RoundTripper construction.

Only depends on the standard library. (Though the WebSocket tests use github.com/coder/websocket).

package main

import (
	"fmt"
	"net/http"

	"github.com/linkdata/httpproxy"
)

func main() {
	mux := http.NewServeMux()
	mux.HandleFunc("/{$}", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, "This is a web proxy server.")
	})
	// the httpproxy.Server will handle CONNECT and absolute URL requests,
	// and all others will be forwarded to the http.Handler we set.
	go http.ListenAndServe(":8080", &httpproxy.Server{Handler: mux})
}