Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
Mux is an HTTP request multiplexer. It matches the URL of each incoming request against a list of registered patterns and calls the handler for the pattern that most closely matches the URL.
Patterns name fixed, rooted paths, like "/favicon.ico", or rooted subtrees, like "/images/" (note the trailing slash). Longer patterns take precedence over shorter ones, so that if there are handlers registered for both "/images/" and "/images/thumbnails/", the latter handler will be called for paths beginning "/images/thumbnails/" and the former will receive requests for any other paths in the "/images/" subtree.
Note that since a pattern ending in a slash names a rooted subtree, the pattern "/" matches all paths not matched by other registered patterns, not just the URL with Path == "/".
If a subtree has been registered and a request is received naming the subtree root without its trailing slash, Mux redirects that request to the subtree root (adding the trailing slash). This behavior can be overridden with a separate registration for the path without the trailing slash. For example, registering "/images/" causes Mux to redirect a request for "/images" to "/images/", unless "/images" has been registered separately.
Patterns may optionally begin with a host name, restricting matches to URLs on that host only. Host-specific patterns take precedence over general patterns, so that a handler might register for the two patterns "/codesearch" and "codesearch.google.com/" without also taking over requests for "http://www.google.com/".
Mux also takes care of sanitizing the URL request path and the Host header, stripping the port number and redirecting any request containing . or .. elements or repeated slashes to an equivalent, cleaner URL.
func (*Mux) Handle ¶
Handle registers the handler for the given pattern. If a handler already exists for pattern, itw ill be overwritten.
func (*Mux) HandleFunc ¶
HandleFunc registers the handler function for the given pattern.
func (*Mux) Handler ¶
Handler returns the handler to use for the given request, consulting r.Method, r.Host, and r.URL.Path. It always returns a non-nil handler. If the path is not in its canonical form, the handler will be an internally-generated handler that redirects to the canonical path. If the host contains a port, it is ignored when matching handlers.
The path and host are used unchanged for CONNECT requests.
Handler also returns the registered pattern that matches the request or, in the case of internally-generated redirects, the pattern that will match after following the redirect.
If there is no registered handler that applies to the request, Handler returns a “page not found” handler and an empty pattern.
type ServerOptions ¶
type ServerOptions struct { // Target server to forward valid traffic to. // The reverse proxy mode will be disabled if this field is nil. Destination *url.URL // Custom Mux to use. Mux *Mux // Whitelisted JA3 hashes. // Only traffic that matches a JA3 from this list will be accepted. // If both Whitelist and Blacklist are specified, Blacklist will precede. // If both Whitelist and Blacklist are unspecified, all traffic will go through. Whitelist []string // Blacklisted JA3 hashes // Traffic that matches a JA3 from this list will be ignored. // If both Whitelist and Blacklist are specified, Blacklist will precede. // If both Whitelist and Blacklist are unspecified, all traffic will go through. Blacklist []string // Called when a JA3 is found on the Blacklist or not on the Whitelist. OnBlocked Handler }
Directories ¶
Path | Synopsis |
---|---|
crypto
|
|
internal/randutil
Package randutil contains internal randomness utilities for various crypto packages.
|
Package randutil contains internal randomness utilities for various crypto packages. |
internal/subtle
Package subtle implements functions that are often useful in cryptographic code but require careful thought to use correctly.
|
Package subtle implements functions that are often useful in cryptographic code but require careful thought to use correctly. |
tls
Package tls partially implements TLS 1.2, as specified in RFC 5246, and TLS 1.3, as specified in RFC 8446.
|
Package tls partially implements TLS 1.2, as specified in RFC 5246, and TLS 1.3, as specified in RFC 8446. |
internal
|
|
profile
Package profile provides a representation of github.com/google/pprof/proto/profile.proto and methods to encode/decode/merge profiles in this format.
|
Package profile provides a representation of github.com/google/pprof/proto/profile.proto and methods to encode/decode/merge profiles in this format. |
net
|
|
http
Package http provides HTTP client and server implementations.
|
Package http provides HTTP client and server implementations. |
http/cgi
Package cgi implements CGI (Common Gateway Interface) as specified in RFC 3875.
|
Package cgi implements CGI (Common Gateway Interface) as specified in RFC 3875. |
http/cookiejar
Package cookiejar implements an in-memory RFC 6265-compliant http.CookieJar.
|
Package cookiejar implements an in-memory RFC 6265-compliant http.CookieJar. |
http/fcgi
Package fcgi implements the FastCGI protocol.
|
Package fcgi implements the FastCGI protocol. |
http/httptest
Package httptest provides utilities for HTTP testing.
|
Package httptest provides utilities for HTTP testing. |
http/httptrace
Package httptrace provides mechanisms to trace the events within HTTP client requests.
|
Package httptrace provides mechanisms to trace the events within HTTP client requests. |
http/httputil
Package httputil provides HTTP utility functions, complementing the more common ones in the net/http package.
|
Package httputil provides HTTP utility functions, complementing the more common ones in the net/http package. |
http/internal
Package internal contains HTTP internals shared by net/http and net/http/httputil.
|
Package internal contains HTTP internals shared by net/http and net/http/httputil. |
http/internal/testcert
Package testcert contains a test-only localhost certificate.
|
Package testcert contains a test-only localhost certificate. |
http/pprof
Package pprof serves via its HTTP server runtime profiling data in the format expected by the pprof visualization tool.
|
Package pprof serves via its HTTP server runtime profiling data in the format expected by the pprof visualization tool. |