mirror of
https://github.com/kataras/iris.git
synced 2026-01-06 03:27:27 +00:00
gofmt -s -w .
Former-commit-id: 6cca675303187f10377a7a713b2e7b3cdf16fd18
This commit is contained in:
@@ -4,6 +4,11 @@
|
||||
|
||||
package context
|
||||
|
||||
// ConfigurationReadOnly can be implemented
|
||||
// by Configuration, it's being used inside the Context.
|
||||
// All methods that it contains should be "safe" to be called by the context
|
||||
// at "serve time". A configuration field may be missing when it's not
|
||||
// safe or its useless to be called from a request handler.
|
||||
type ConfigurationReadOnly interface {
|
||||
// GetVHost returns the non-exported vhost config field.
|
||||
//
|
||||
|
||||
@@ -85,6 +85,10 @@ type GzipResponseWriter struct {
|
||||
|
||||
var _ ResponseWriter = &GzipResponseWriter{}
|
||||
|
||||
// BeginGzipResponse accepts a ResponseWriter
|
||||
// and prepares the new gzip response writer.
|
||||
// It's being called per-handler, when caller decide
|
||||
// to change the response writer type.
|
||||
func (w *GzipResponseWriter) BeginGzipResponse(underline ResponseWriter) {
|
||||
w.ResponseWriter = underline
|
||||
w.gzipWriter = acquireGzipWriter(w.ResponseWriter)
|
||||
@@ -92,6 +96,8 @@ func (w *GzipResponseWriter) BeginGzipResponse(underline ResponseWriter) {
|
||||
w.disabled = false
|
||||
}
|
||||
|
||||
// EndResponse called right before the contents of this
|
||||
// response writer are flushed to the client.
|
||||
func (w *GzipResponseWriter) EndResponse() {
|
||||
releaseGzipResponseWriter(w)
|
||||
w.ResponseWriter.EndResponse()
|
||||
@@ -104,6 +110,8 @@ func (w *GzipResponseWriter) Write(contents []byte) (int, error) {
|
||||
return len(w.chunks), nil
|
||||
}
|
||||
|
||||
// FlushResponse validates the response headers in order to be compatible with the gzip written data
|
||||
// and writes the data to the underline ResponseWriter.
|
||||
func (w *GzipResponseWriter) FlushResponse() {
|
||||
if w.disabled {
|
||||
w.ResponseWriter.Write(w.chunks)
|
||||
@@ -128,7 +136,7 @@ func (w *GzipResponseWriter) ResetBody() {
|
||||
w.chunks = w.chunks[0:0]
|
||||
}
|
||||
|
||||
// Disable, disables the gzip compression for the next .Write's data,
|
||||
// Disable turns of the gzip compression for the next .Write's data,
|
||||
// if called then the contents are being written in plain form.
|
||||
func (w *GzipResponseWriter) Disable() {
|
||||
w.disabled = true
|
||||
|
||||
@@ -4,6 +4,23 @@
|
||||
|
||||
package context
|
||||
|
||||
// A Handler responds to an HTTP request.
|
||||
// It writes reply headers and data to the Context.ResponseWriter() and then return.
|
||||
// Returning signals that the request is finished;
|
||||
// it is not valid to use the Context after or concurrently with the completion of the Handler call.
|
||||
//
|
||||
// Depending on the HTTP client software, HTTP protocol version,
|
||||
// and any intermediaries between the client and the Iris server,
|
||||
// it may not be possible to read from the Context.Request().Body after writing to the context.ResponseWriter().
|
||||
// Cautious handlers should read the Context.Request().Body first, and then reply.
|
||||
//
|
||||
// Except for reading the body, handlers should not modify the provided Context.
|
||||
//
|
||||
// If Handler panics, the server (the caller of Handler) assumes that the effect of the panic was isolated to the active request.
|
||||
// It recovers the panic, logs a stack trace to the server error log, and hangs up the connection.
|
||||
type Handler func(Context)
|
||||
|
||||
// Handlers is just a type of slice of []Handler.
|
||||
//
|
||||
// See `Handler` for more.
|
||||
type Handlers []Handler
|
||||
|
||||
Reference in New Issue
Block a user