srvCtx

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContextPool = sync.Pool{
	New: func() interface{} {
		return &Ctx{
			Request: Request{
				Body:    make([]byte, 0),
				Headers: http.Header{},
			},
			Response: Response{
				Body:        make([]byte, 0),
				StatusCode:  200,
				ContentType: "application/json; charset=utf-8",
			},
			Values: make(map[string]interface{}, 10),
		}
	},
}

Functions

This section is empty.

Types

type Cookie struct {
	Name    string
	Value   string
	Path    string
	Expires time.Duration
}

func (Cookie) String

func (t Cookie) String(domain string, sameSite string, httpOnly bool, secure bool) string

type Ctx

type Ctx struct {
	Request  Request
	Response Response
	Values   map[string]interface{}
}

func FromHttp

func FromHttp(request *http.Request) *Ctx

type Request

type Request struct {
	Body     []byte
	Headers  http.Header
	Ip       string
	URI      string
	Method   string
	Host     string
	PostForm url.Values
}

type Response

type Response struct {
	Body        []byte
	ContentType string
	StatusCode  int
	Headers     map[string]string
	Cookie      []Cookie
}

Jump to

Keyboard shortcuts

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