{"modulePath":"github.com/weiwolves/pkg","version":"v0.0.0-20200322065615-581c8d33cff6","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package responseproxy\n\nPackage responseproxy provides various proxy functions for extending http.ResponseWriter.\n\nTODO: Use idea from [https://github.com/felixge/httpsnoop/blob/master/wrap.go](https://github.com/felixge/httpsnoop/blob/master/wrap.go)\n\n## Types\n\n```go\ntype BufferedWriter interface {\n\thttp.ResponseWriter\n\t// Unwrap returns the original proxied target.\n\tUnwrap() http.ResponseWriter\n}\n```\nBufferedWriter is a proxy around an http.ResponseWriter that allows you write the response body into a buffer instead of directly writing to the client. You must take care that the buffer gets written to the client. Calls to Flush() do not flush the buffer. Headers gets written directly to the client.\n\n```go\nfunc WrapBuffered(buf io.Writer, w http.ResponseWriter) BufferedWriter\n```\nWrapBuffered wraps an http.ResponseWriter, returning a proxy which only writes into the provided io.Writer.\n\n```go\ntype PipedWriter interface {\n\thttp.ResponseWriter\n\t// Close must be called to terminate the internal goroutine.\n\tClose() error\n\t// Unwrap returns the original proxied target.\n\tUnwrap() http.ResponseWriter\n}\n```\nPipedWriter is a proxy around an http.ResponseWriter that allows you write the response body into a pipe instead of directly writing to the client. You must take care that the pipe output (the reader) gets written to the client. Calls to Flush() do not flush the pipe. Headers gets written directly to the client.\n\n```go\nfunc WrapPiped(iorf io.ReaderFrom, w http.ResponseWriter) PipedWriter\n```\nWrapPiped wraps an http.ResponseWriter, returning a proxy which pipes the writes to your ReaderFrom. You must call \"defer Close()\" to quite the internal goroutine.\n\n```go\ntype TeeWriter interface {\n\thttp.ResponseWriter\n\t// Status returns the HTTP status of the request, or 0 if one has not\n\t// yet been sent.\n\tStatus() int\n\t// BytesWritten returns the total number of bytes sent to the client.\n\tBytesWritten() int\n\t// Tee causes the response body to be written to the given io.Writer in\n\t// addition to proxying the writes through. Only one io.Writer can be\n\t// tee'd to at once: setting a second one will overwrite the first.\n\t// Writes will be sent to the proxy before being written to this\n\t// io.Writer. It is illegal for the tee'd writer to be modified\n\t// concurrently with writes.\n\tTee(io.Writer)\n\t// Unwrap returns the original proxied target.\n\tUnwrap() http.ResponseWriter\n}\n```\nTeeWriter is a proxy around an http.ResponseWriter that allows you to hook into various parts of the response process.\n\n```go\nfunc WrapTee(w http.ResponseWriter) TeeWriter\n```\nWrapTee wraps an http.ResponseWriter, returning a proxy that allows you to hook into various parts of the response process.\n\n","path":"github.com/weiwolves/pkg/net/responseproxy","name":"responseproxy","synopsis":"Package responseproxy provides various proxy functions for extending http.ResponseWriter.","isRedistributable":true}
