LocalLogger is a logger that can be used when running locally (i.e.: not on
GCP)
Log implements the Logger interface via our internal log package.
T : Logger
cacheRecorder is an http.ResponseWriter that collects http bytes for later
writing to the cache. Along the way it collects any error, along with the
resulting HTTP status code. We only cache 200 OK responses.
ResponseWriterhttp.ResponseWriterbuf*bytes.BufferbufErrerrorstatusCodeintzipWriter*gzip.Writer
Header returns the header map that will be sent by
WriteHeader. The Header map also is the mechanism with which
Handlers can set HTTP trailers.
Changing the header map after a call to WriteHeader (or
Write) has no effect unless the modified headers are
trailers.
There are two ways to set Trailers. The preferred way is to
predeclare in the headers which trailers you will later
send by setting the "Trailer" header to the names of the
trailer keys which will come later. In this case, those
keys of the Header map are treated as if they were
trailers. See the example. The second way, for trailer
keys not known to the Handler until after the first Write,
is to prefix the Header map keys with the TrailerPrefix
constant value. See TrailerPrefix.
To suppress automatic response headers (such as "Date"), set
their value to nil.
(*T) Write(b []byte) (int, error)(*T) WriteHeader(statusCode int)
*T : github.com/go-git/go-git/v5/plumbing/protocol/packp/sideband.Progress
*T : github.com/jbenet/go-context/io.Writer
*T : io.Writer
*T : net/http.ResponseWriter
func newRecorder(w http.ResponseWriter) *cacheRecorder
ResponseWriterhttp.ResponseWriterbypassboolstatusint
Header returns the header map that will be sent by
WriteHeader. The Header map also is the mechanism with which
Handlers can set HTTP trailers.
Changing the header map after a call to WriteHeader (or
Write) has no effect unless the modified headers are
trailers.
There are two ways to set Trailers. The preferred way is to
predeclare in the headers which trailers you will later
send by setting the "Trailer" header to the names of the
trailer keys which will come later. In this case, those
keys of the Header map are treated as if they were
trailers. See the example. The second way, for trailer
keys not known to the Handler until after the first Write,
is to prefix the Header map keys with the TrailerPrefix
constant value. See TrailerPrefix.
To suppress automatic response headers (such as "Date"), set
their value to nil.
Write writes the data to the connection as part of an HTTP reply.
If WriteHeader has not yet been called, Write calls
WriteHeader(http.StatusOK) before writing the data. If the Header
does not contain a Content-Type line, Write adds a Content-Type set
to the result of passing the initial 512 bytes of written data to
DetectContentType. Additionally, if the total size of all written
data is under a few KB and there are no Flush calls, the
Content-Length header is added automatically.
Depending on the HTTP protocol version and the client, calling
Write or WriteHeader may prevent future reads on the
Request.Body. For HTTP/1.x requests, handlers should read any
needed request body data before writing the response. Once the
headers have been flushed (due to either an explicit Flusher.Flush
call or writing enough data to trigger a flush), the request body
may be unavailable. For HTTP/2 requests, the Go HTTP server permits
handlers to continue to read the request body while concurrently
writing the response. However, such behavior may not be supported
by all HTTP/2 clients. Handlers should read before writing if
possible to maximize compatibility.
(*T) WriteHeader(code int)
T : github.com/go-git/go-git/v5/plumbing/protocol/packp/sideband.Progress
T : github.com/jbenet/go-context/io.Writer
T : io.Writer
*T : net/http.ResponseWriter
ResponseWriterhttp.ResponseWriterstatusint
Header returns the header map that will be sent by
WriteHeader. The Header map also is the mechanism with which
Handlers can set HTTP trailers.
Changing the header map after a call to WriteHeader (or
Write) has no effect unless the modified headers are
trailers.
There are two ways to set Trailers. The preferred way is to
predeclare in the headers which trailers you will later
send by setting the "Trailer" header to the names of the
trailer keys which will come later. In this case, those
keys of the Header map are treated as if they were
trailers. See the example. The second way, for trailer
keys not known to the Handler until after the first Write,
is to prefix the Header map keys with the TrailerPrefix
constant value. See TrailerPrefix.
To suppress automatic response headers (such as "Date"), set
their value to nil.
Write writes the data to the connection as part of an HTTP reply.
If WriteHeader has not yet been called, Write calls
WriteHeader(http.StatusOK) before writing the data. If the Header
does not contain a Content-Type line, Write adds a Content-Type set
to the result of passing the initial 512 bytes of written data to
DetectContentType. Additionally, if the total size of all written
data is under a few KB and there are no Flush calls, the
Content-Length header is added automatically.
Depending on the HTTP protocol version and the client, calling
Write or WriteHeader may prevent future reads on the
Request.Body. For HTTP/1.x requests, handlers should read any
needed request body data before writing the response. Once the
headers have been flushed (due to either an explicit Flusher.Flush
call or writing enough data to trigger a flush), the request body
may be unavailable. For HTTP/2 requests, the Go HTTP server permits
handlers to continue to read the request body while concurrently
writing the response. However, such behavior may not be supported
by all HTTP/2 clients. Handlers should read before writing if
possible to maximize compatibility.
(*T) WriteHeader(code int)
T : github.com/go-git/go-git/v5/plumbing/protocol/packp/sideband.Progress
T : github.com/jbenet/go-context/io.Writer
T : io.Writer
*T : net/http.ResponseWriter
statsKey is the type of the context key for stats.
statsResponseWriter is an http.ResponseWriter that tracks statistics about
the page being written.
hasherhash.Hash64
// required for a ResponseWriter; ignored
// start time of request
statsPageStats
Header implements http.ResponseWriter.Header.
Write implements http.ResponseWriter.Write by
tracking statistics about the data being written.
WriteHeader implements http.ResponseWriter.WriteHeader.
WriteStats writes the statistics to w.
*T : github.com/go-git/go-git/v5/plumbing/protocol/packp/sideband.Progress
*T : github.com/jbenet/go-context/io.Writer
*T : io.Writer
*T : net/http.ResponseWriter
func newStatsResponseWriter() *statsResponseWriter
Package-Level Functions (total 32, in which 18 are exported)
AcceptRequests serves 405 (Method Not Allowed) for any method not on the
given list and 414 (Method Request URI Too Long) for any URI that exceeds
the maxURILength.
BetaPkgGoDevRedirect redirects requests from pkg.go.dev to beta.pkg.go.dev,
based on whether a cookie is set for betapkggodev-redirect. The cookie
can be turned on/off using a query param.
Cache returns a new Middleware that caches every request.
The name of the cache is used only for metrics.
The expirer is a func that is used to map a new request to its TTL.
authHeader is the header key used by the cache to know that a
request should bypass the cache.
authValues is the set of values that could be set on the authHeader in
order to bypass the cache.
Chain creates a new Middleware that applies a sequence of Middlewares, so
that they execute in the given order when handling an http request.
In other words, Chain(m1, m2)(handler) = m1(m2(handler))
A similar pattern is used in e.g. github.com/justinas/alice:
https://github.com/justinas/alice/blob/ce87934/chain.go#L45
ElapsedStat records as a stat the elapsed time for a
function execution. Invoke like so:
defer ElapsedStat(ctx, "FunctionName")()
The resulting stat will be called "FunctionName ms" and will
be the wall-clock execution time of the function in milliseconds.
ErrorReporting returns a middleware that reports any server errors using the
report func.
Experiment returns a new Middleware that sets active experiments for each
incoming request.
Identity is a middleware that does nothing. It can be used as a helper when
building middleware chains.
NewExperimenter returns an Experimenter for use in the middleware. The
experimenter regularly polls for updates to the snapshot in the background.
Panic returns a middleware that executes panicHandler on any panic
originating from the delegate handler.
Quota implements a simple IP-based rate limiter. Each set of incoming IP
addresses with the same low-order byte gets settings.QPS requests per second.
Information is kept in a redis instance.
If a request is disallowed, a 429 (TooManyRequests) will be served.
RequestLog returns a middleware that logs each incoming requests using the
given logger. This logger replaces the built-in appengine request logger,
which logged PII when behind IAP, in such a way that was impossible to turn
off.
Logs may be viewed in Pantheon by selecting the log source corresponding to
the AppEngine service name (e.g. 'dev-worker').
SecureHeaders adds a content-security-policy and other security-related
headers to all responses.
SetStat sets a stat named key in the current context. If key already has a
value, the old and new value are both stored in a slice.
Stats returns a Middleware that, instead of serving the page,
serves statistics about the page.
Timeout returns a new Middleware that times out each request after the given
duration.
TTL returns an Expirer that expires all pages after the given TTL.
ValidateIAPHeader checks that the request has a header that proves it arrived
via the IAP.
See https://cloud.google.com/iap/docs/signed-headers-howto#securing_iap_headers.
shouldSetExperiment reports whether a given request should be enrolled in
the experiment, based on the ip. e.Name, and e.Rollout.
Requests from empty ip addresses are never enrolled.
All requests from the same IP will be enrolled in the same set of
experiments.
The pages are generated with Goldsv0.3.2-preview. (GOOS=darwin GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.