Documentation
¶
Index ¶
- Constants
- type Response
- func (r *Response) BodyTransformer(w bodyTransformFnc)
- func (r *Response) Close()
- func (r *Response) Copy() (*Response, error)
- func (r *Response) CopyBody() ([]byte, error)
- func (r *Response) CopyHeadersFrom(src *Response)
- func (r *Response) CopyWithStream() (*Response, error)
- func (r *Response) DecodeMsgpack(dec *msgpack.Decoder) error
- func (r *Response) EncodeMsgpack(enc *msgpack.Encoder) error
- func (r *Response) Error() error
- func (r *Response) GetTTL() int
- func (r *Response) HasError() bool
- func (r *Response) IsBuffered() bool
- func (r *Response) IsCacheable() bool
- func (r *Response) IsImage() bool
- func (r *Response) ReadBody() ([]byte, error)
- func (r *Response) Send(w http.ResponseWriter) error
- func (r *Response) SendContent(req *http.Request, w http.ResponseWriter) error
- func (r *Response) Set(headerName string, headerValue string)
- func (r *Response) SetContentType(contentType string) *Response
- func (r *Response) SetDebug(obj *object.FileObject) *Response
- func (r *Response) Stream() io.ReadCloser
Constants ¶
const (
// HeaderContentType name of Content-Type header
HeaderContentType = "content-type"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Response ¶
type Response struct { StatusCode int // status code of response Headers http.Header // headers for response ContentLength int64 // if buffered response contains length of buffer, for streams it equal to -1 // contains filtered or unexported fields }
Response is helper struct for wrapping different storage response
func New ¶
func New(statusCode int, body io.ReadCloser) *Response
New create response object with io.ReadCloser
func NewNoContent ¶
NewNoContent create response object without content
func (*Response) BodyTransformer ¶ added in v0.11.0
func (r *Response) BodyTransformer(w bodyTransformFnc)
BodyTransformer add function that will transform body before send to client
func (*Response) CopyBody ¶
CopyBody read all content of response and returns it in []byte but doesn't change response object body
func (*Response) CopyHeadersFrom ¶
CopyHeadersFrom copy all headers from src response but body is omitted
func (*Response) CopyWithStream ¶
CopyWithStream should be used with not buffered response that contain stream it try duplicate response stream for multiple readers
func (*Response) DecodeMsgpack ¶ added in v0.13.0
func (*Response) EncodeMsgpack ¶ added in v0.13.0
func (*Response) IsBuffered ¶
IsBuffered check if response has access to original buffer
func (*Response) IsCacheable ¶ added in v0.13.0
func (*Response) ReadBody ¶
ReadBody reads all content of response and returns []byte Content of the response is changed Such response shouldn't be Send to client
func (*Response) Send ¶
func (r *Response) Send(w http.ResponseWriter) error
Send write response to client using streaming
func (*Response) SendContent ¶ added in v0.3.0
SendContent use http.ServeContent to return response to client It can handle range and condition requests In this function we don't need to use transformer because it don't serve whole body It is used for range and condition requests
func (*Response) SetContentType ¶
SetContentType update content type header of response
func (*Response) SetDebug ¶
func (r *Response) SetDebug(obj *object.FileObject) *Response
SetDebug set flag indicating that response can including debug information
func (*Response) Stream ¶
func (r *Response) Stream() io.ReadCloser
Stream return io.Reader interface from correct response content