context

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Content_Type_Key       = "Content-Type"
	Content_Type_Json      = "application/json"
	Content_Type_Xml       = "text/xml"
	Content_Type_Html      = "text/html"
	Content_Type_Form      = "application/x-www-form-urlencoded"
	Content_Type_Binary    = "application/octet-stream"
	Header_X_Real_Ip       = "X-Real-IP"
	Header_X_Forwarded_For = "X-Forwarded-For"
)

Variables

This section is empty.

Functions

func IsBinary

func IsBinary(t string) bool

func IsForm

func IsForm(t string) bool

func IsJson

func IsJson(t string) bool

func IsXml

func IsXml(t string) bool

Types

type ActionInterface

type ActionInterface interface {
	Action(c *Context) error
	View() view.ViewInterface
	Services() []krpc.ServiceName
	Group() string
}

type Context

type Context struct {
	*object.ObjNoCtx
	*pool.Context

	Request *http.Request

	Params Params

	Rpcs Rpcs
	// contains filtered or unexported fields
}

func NewContext

func NewContext(parent context.Context, w http.ResponseWriter, r *http.Request) *Context

func (*Context) Binary

func (c *Context) Binary(status int, data []byte) error

func (*Context) ClientIp

func (c *Context) ClientIp() string

func (*Context) Data

func (c *Context) Data(status int, contentType string, data []byte) error

func (*Context) Get

func (c *Context) Get(key string) (any, bool)

func (*Context) GetBool

func (c *Context) GetBool(key string) bool

func (*Context) GetHeader

func (c *Context) GetHeader(key string) string

func (*Context) GetInt

func (c *Context) GetInt(key string) int

func (*Context) GetInt32

func (c *Context) GetInt32(key string) int32

func (*Context) GetInt64

func (c *Context) GetInt64(key string) int64

func (*Context) GetStatus

func (c *Context) GetStatus() int

func (*Context) GetString

func (c *Context) GetString(key string) string

func (*Context) Header

func (c *Context) Header(key, val string)

func (*Context) Html

func (c *Context) Html(status int, data Data) error

func (*Context) IsTimeout

func (c *Context) IsTimeout() bool

func (*Context) Json

func (c *Context) Json(status int, data any) error

func (*Context) Middlerware

func (c *Context) Middlerware(middlewares ...MiddlewareInterface)

func (*Context) MiddlerwareStart

func (c *Context) MiddlerwareStart()

func (*Context) Next

func (c *Context) Next()

func (*Context) ParseJson

func (c *Context) ParseJson(data rule.ParamInterface) error

func (*Context) ParseXml

func (c *Context) ParseXml(data rule.ParamInterface) error

func (*Context) Raw

func (c *Context) Raw() ([]byte, error)

func (*Context) Reset

func (c *Context) Reset()

func (*Context) Set

func (c *Context) Set(key string, val any)

func (*Context) SetAction

func (c *Context) SetAction(ac ActionInterface)

func (*Context) SetParams

func (c *Context) SetParams(ps Params)

func (*Context) Status

func (c *Context) Status(status int)

func (*Context) WithTimeout

func (c *Context) WithTimeout(timeout time.Duration) context.CancelFunc

func (*Context) Writer

func (c *Context) Writer() http.ResponseWriter

func (*Context) Xml

func (c *Context) Xml(status int, data any) error

type Data

type Data map[string]any

type MiddlewareInterface

type MiddlewareInterface interface {
	Handle(*Context)
}

type Params

type Params map[string]string

func (Params) GetBool

func (p Params) GetBool(key string) bool

func (Params) GetFloat

func (p Params) GetFloat(key string) float64

func (Params) GetInt

func (p Params) GetInt(key string) int

func (Params) GetString

func (p Params) GetString(key string) string

func (Params) Reset

func (p Params) Reset()

type Rpcs

func (Rpcs) Add

func (r Rpcs) Add(serviceName krpc.ServiceName, group string, conn grpc.ClientConnInterface)

func (Rpcs) AddDefualt

func (r Rpcs) AddDefualt(serviceName krpc.ServiceName, conn grpc.ClientConnInterface)

func (Rpcs) Default

func (r Rpcs) Default(serviceName krpc.ServiceName) grpc.ClientConnInterface

func (Rpcs) Get

func (r Rpcs) Get(serviceName krpc.ServiceName, group string) grpc.ClientConnInterface

type SafeMap added in v0.0.7

type SafeMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewSafeMap added in v0.0.7

func NewSafeMap[K comparable, V any]() *SafeMap[K, V]

func (*SafeMap[K, V]) Add added in v0.0.7

func (s *SafeMap[K, V]) Add(key K, val V)

func (*SafeMap[K, V]) For added in v0.0.7

func (s *SafeMap[K, V]) For(f func(key K, val V) bool)

func (*SafeMap[K, V]) Get added in v0.0.7

func (s *SafeMap[K, V]) Get(key K) V

func (*SafeMap[K, V]) Len added in v0.0.7

func (s *SafeMap[K, V]) Len() int

func (*SafeMap[K, V]) Rem added in v0.0.7

func (s *SafeMap[K, V]) Rem(key K)

Jump to

Keyboard shortcuts

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