Examples using... "net/http"
Recent
This example fetches several URLs concurrently,
using a WaitGroup to block until all the fetches are complete.
StripPrefix returns a handler that serves HTTP requests
by removing the given prefix from the request URL's Path
and invoking the handler h. StripPrefix handles a
request for a path that doesn't begin with prefix by
replying with an HTTP 404 not found error.
Shutdown gracefully shuts down the server without interrupting any
active connections. Shutdown works by first closing all open
listeners, then closing all idle connections, and then waiting
indefinitely for connections to return to idle and then shut down.
If the provided context expires before the...
Handle registers the handler for the given pattern.
If a handler already exists for pattern, Handle panics.
HTTP Trailers are a set of key/value pairs like headers that come
after the HTTP response, instead of before.
NotFoundHandler returns a simple request handler
that replies to each request with a “404 page not found” reply.
ListenAndServeTLS acts identically to ListenAndServe, except that it
expects HTTPS connections. Additionally, files containing a certificate and
matching private key for the server must be provided. If the certificate
is signed by a certificate authority, the certFile should be the concatenation
of ...
ListenAndServe listens on the TCP network address addr and then calls
Serve with handler to handle requests on incoming connections.
Accepted connections are configured to enable TCP keep-alives.
The Hijacker interface is implemented by ResponseWriters that allow
an HTTP handler to take over the connection.
HandleFunc registers the handler function for the given pattern
in the DefaultServeMux.
The documentation for ServeMux explains how patterns are matched.
Handle registers the handler for the given pattern
in the DefaultServeMux.
The documentation for ServeMux explains how patterns are matched.
Get issues a GET to the specified URL. If the response is one of
the following redirect codes, Get follows the redirect, up to a
maximum of 10 redirects:
FileServer returns a handler that serves HTTP requests
with the contents of the file system rooted at root.
FileServer returns a handler that serves HTTP requests
with the contents of the file system rooted at root.
FileServer returns a handler that serves HTTP requests
with the contents of the file system rooted at root.
ReverseProxy is an HTTP Handler that takes an incoming request and
sends it to another server, proxying the response back to the
client.
DumpResponse is like DumpRequest but dumps a response.
DumpRequestOut is like DumpRequest but for outgoing client requests. It
includes any headers that the standard http.Transport adds, such as
User-Agent.
DumpRequest returns the given request in its HTTP/1.x wire
representation. It should only be used by servers to debug client
requests. The returned representation is an approximation only;
some details of the initial request are lost while parsing it into
an http.Request. In particular, the order an...
Package httptrace provides mechanisms to trace the events within
HTTP client requests.
A Server is an HTTP server listening on a system-chosen port on the
local loopback interface, for use in end-to-end HTTP tests.
ResponseRecorder is an implementation of http.ResponseWriter that
records its mutations for later inspection in tests.