Documentation
¶
Overview ¶
Response package provides the core functionality of handling the client connection, chunked response and other features
Index ¶
- type Response
- func (res *Response) AddCookie(key string, value string)
- func (res *Response) AddFinishedListener(callback func())
- func (res *Response) AddHeaderListener(callback func())
- func (res *Response) End()
- func (res *Response) Error(status int, str string)
- func (res *Response) GetBuffer() *bufio.ReadWriter
- func (res *Response) GetConnection() net.Conn
- func (res *Response) GetProp(key string) interface{}
- func (res *Response) GetRaw() http.ResponseWriter
- func (res *Response) HasEnded() bool
- func (res *Response) Init(rs http.ResponseWriter, r *http.Request, w *bufio.ReadWriter, con net.Conn) *Response
- func (res *Response) JSON(content interface{})
- func (res *Response) Redirect(url string) *Response
- func (res *Response) Send(content string) *Response
- func (res *Response) SetProp(key string, value interface{})
- func (res *Response) WriteChunk(content string) *Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Response ¶
type Response struct {
Header *header.Header
Cookie *cookie.Cookie
Locals map[string]interface{}
Props map[string]interface{}
// contains filtered or unexported fields
}
Response Structure extends basic http.ResponseWriter interface It encapsulates Header and Cookie class for direct access
func (*Response) AddFinishedListener ¶
func (res *Response) AddFinishedListener(callback func())
func (*Response) AddHeaderListener ¶
func (res *Response) AddHeaderListener(callback func())
func (*Response) End ¶
func (res *Response) End()
Ends a response and drops the connection with client
func (*Response) GetBuffer ¶
func (res *Response) GetBuffer() *bufio.ReadWriter
A helper for middlewares to get the original Request buffer
func (*Response) GetConnection ¶
A helper for middlewares to get the original net.Conn
func (*Response) GetRaw ¶
func (res *Response) GetRaw() http.ResponseWriter
A helper for middlewares to get the original http.ResponseWriter
func (*Response) Init ¶
func (res *Response) Init(rs http.ResponseWriter, r *http.Request, w *bufio.ReadWriter, con net.Conn) *Response
Intialise the Response Struct, requires the Hijacked buffer, connection and Response interface
func (*Response) JSON ¶
func (res *Response) JSON(content interface{})
Send JSON response, takes interface as input
func (*Response) WriteChunk ¶
Writes a string content to the buffer and immediately flushes the same