response

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2017 License: MIT Imports: 15 Imported by: 0

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 NextFunc

type NextFunc func(NextFunc)

type Response

type Response struct {
	Header *header.Header
	Cookie *cookie.Cookie
	Locals 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) Download

func (res *Response) Download(path string, file_name string) bool

Send a download file to the client

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) 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, props *map[string]interface{}) *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) SendFile

func (res *Response) SendFile(url string, noCache bool) bool

Reads a file in buffer and writes it to the socket It also checks with the existing E-Tags list so as to provide caching.

func (*Response) Write

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

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

func (*Response) WriteBytes

func (res *Response) WriteBytes(bytes []byte) *Response

Writes an array of bytes to the socket

Jump to

Keyboard shortcuts

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