Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadCloserSplit ¶
func ReadCloserSplit(readCloser io.ReadCloser, splits int) []io.ReadCloser
ReadCloserSplit takes an io.ReadCloser and splits it into multiple io.ReadCloser interfaces that each read from the same upstream reader. Bytes are read in as necessary when any of the downstream readers perform a read, they are then buffered until the remaining readers have been able to read them. This ensures that each reader is able to read the entire upstream content but minimises the active memory usage which would otherwise be incurred of we slurped the entire content upfront
Types ¶
type Alternative ¶
Alternative implements a http.Handler which wraps another http.Handler and tries serving it first. Depending on the status returned by the first handler it will either return the response to the caller immediately or it will pass a copy of the request to the second handler instead, retuning that handlers response in that case.
func (*Alternative) ServeHTTP ¶
func (alternative *Alternative) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*Alternative) WhenStatus ¶
func (alternative *Alternative) WhenStatus(status int) *AlternativeBuilder
type AlternativeBuilder ¶
type AlternativeBuilder struct {
// contains filtered or unexported fields
}
AlternativeBuilder is a struct that helps to build a fallback handler by the use of a narrative structure for example using the following:
fallback.Try(handler1).WhenStatus(http.StatusNotFound).Then(handler2)
func Try ¶
func Try(h http.Handler) *AlternativeBuilder
Try takes a `http.Handler` and returns an incomplete AlternativeBuilder
func (*AlternativeBuilder) Then ¶
func (ab *AlternativeBuilder) Then(handler http.Handler) *Alternative
Then takes an AlternativeBuilder and returns a complete Alternative with the fallback handler provided
func (*AlternativeBuilder) WhenStatus ¶
func (ab *AlternativeBuilder) WhenStatus(status int) *AlternativeBuilder
WhenStatus extends an AlternativeBuilder and includes a condition on the http status