context

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cookie struct {
	Config *CookieConfig
}

func (*Cookie) Set

func (c *Cookie) Set(name interface{}, params ...interface{}) (*http.Cookie, error)

type CookieConfig

type CookieConfig struct {
	Prefix string

	Path       string    // optional
	Domain     string    // optional
	Expires    time.Time // optional
	RawExpires string    // for reading cookies only

	// MaxAge=0 means no 'Max-Age' attribute specified.
	// MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'
	// MaxAge>0 means Max-Age attribute present and given in seconds
	MaxAge   int
	Secure   bool
	HttpOnly bool
	Raw      string
	Unparsed []string // Raw text of unparsed attribute-value pairs
}

type File

type File struct {
	FileHeader *multipart.FileHeader
}

func (*File) Move

func (f *File) Move(directory string, name ...string) (bool, error)

type Request

type Request struct {
	Request *http.Request

	CookieHandler *Cookie
	// contains filtered or unexported fields
}

Request HTTP request

func NewRequest

func NewRequest(req *http.Request) *Request

NewRequest create a new HTTP request from *http.Request

func (*Request) All

func (r *Request) All(keys ...string) map[string]string

All get all of the input and query for the request.

func (*Request) AllFiles

func (r *Request) AllFiles() (map[string]*File, error)

AllFiles returns all files from the request.

func (*Request) Cookie

func (r *Request) Cookie(key string, value ...string) (string, error)

Cookie Retrieve a cookie from the request.

func (*Request) Except

func (r *Request) Except(keys ...string) map[string]string

Except Get all of the input except for a specified array of items.

func (*Request) Exists

func (r *Request) Exists(keys ...string) bool

Has Determine if the request contains a given input item key.

func (*Request) File

func (r *Request) File(key string) (*File, error)

File returns a file from the request.

func (*Request) FullUrl

func (r *Request) FullUrl() string

FullUrl get the full URL for the request.

func (*Request) GetHttpRequest

func (r *Request) GetHttpRequest() *http.Request

GetHttpRequest get Current *http.Request

func (*Request) GetMethod

func (r *Request) GetMethod() string

GetMethod get the request method.

func (*Request) GetPath

func (r *Request) GetPath() string

GetPath get the request path.

func (*Request) Has

func (r *Request) Has(keys ...string) bool

Filled Determine if the request contains a non-empty value for an input item.

func (*Request) Input

func (r *Request) Input(key string, value ...string) (string, error)

Input returns a input item from the request.

func (*Request) IsMethod

func (r *Request) IsMethod(m string) bool

IsMethod checks if the request method is of specified type.

func (*Request) Method

func (r *Request) Method() string

Method get the current method for the request.

func (*Request) Only

func (r *Request) Only(keys ...string) map[string]string

Only get a subset of the items from the input data.

func (*Request) Path

func (r *Request) Path() string

Path get the current path info for the request.

func (*Request) Post

func (r *Request) Post(key string, value ...string) (string, error)

Input returns a post item from the request.

func (*Request) Query

func (r *Request) Query(key string, value ...string) (string, error)

Query returns a query string item from the request.

func (*Request) Session

func (r *Request) Session() Session

Session get the session associated with the request.

func (*Request) SetSession

func (r *Request) SetSession(s Session)

Session set the session associated with the request.

func (*Request) Url

func (r *Request) Url() string

Url get the URL (no query string) for the request.

type Response

type Response struct {
	CookieHandler *Cookie
	// contains filtered or unexported fields
}

func (*Response) Cookie

func (r *Response) Cookie(name interface{}, params ...interface{}) error

Cookie Add a cookie to the response.

func (*Response) GetCharset

func (r *Response) GetCharset() string

GetContentType get the Charset on the response.

func (*Response) GetCode

func (r *Response) GetCode() int

GetCode get the response status code.

func (*Response) GetContent

func (r *Response) GetContent() string

GetCode get the response content.

func (*Response) GetContentType

func (r *Response) GetContentType() string

GetContentType get the Content-Type on the response.

func (*Response) Send

func (r *Response) Send(w http.ResponseWriter)

Send Sends HTTP headers and content.

func (*Response) SetCharset

func (r *Response) SetCharset(val string)

GetContentType sets the Charset on the response.

func (*Response) SetCode

func (r *Response) SetCode(val int)

SetCode sets the status code on the response.

func (*Response) SetContent

func (r *Response) SetContent(val string)

SetContent sets the content on the response.

func (*Response) SetContentType

func (r *Response) SetContentType(val string)

GetContentType sets the Content-Type on the response.

type Session

type Session interface {
	Get(name string, value ...interface{}) interface{}

	Set(name string, value interface{})

	All() map[string]interface{}

	Remove(name string) interface{}

	Forget(names ...string)

	Clear()

	Save()
}

Jump to

Keyboard shortcuts

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