response

package
v0.0.0-...-0fda7bc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2016 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Response package provides the core functionality of handling the client connection, chunked response and other features

Index

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) AddCookie

func (res *Response) AddCookie(key string, value string)

This function is for internal Use by Cookie Struct

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) Error

func (res *Response) Error(status int, str string)

Send Error, takes HTTP status and a string content

func (*Response) GetBuffer

func (res *Response) GetBuffer() *bufio.ReadWriter

A helper for middlewares to get the original Request buffer

func (*Response) GetConnection

func (res *Response) GetConnection() net.Conn

A helper for middlewares to get the original net.Conn

func (*Response) GetProp

func (res *Response) GetProp(key string) interface{}

func (*Response) GetRaw

func (res *Response) GetRaw() http.ResponseWriter

A helper for middlewares to get the original http.ResponseWriter

func (*Response) HasEnded

func (res *Response) HasEnded() bool

An internal package use function to check the state of connection

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) Redirect

func (res *Response) Redirect(url string) *Response

Redirects a request, takes the url as the Location

func (*Response) Send

func (res *Response) Send(content string) *Response

func (*Response) SetProp

func (res *Response) SetProp(key string, value interface{})

func (*Response) WriteChunk

func (res *Response) WriteChunk(content string) *Response

Writes a string content to the buffer and immediately flushes the same

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL