request

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: Apache-2.0 Imports: 5 Imported by: 40

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CTX

type CTX interface {
	T(string, ...interface{}) string
	GetT() i18n.TranslateFunc
	Session() *model.Session
	RequestId() string
	IPAddress() string
	XForwardedFor() string
	Path() string
	UserAgent() string
	AcceptLanguage() string
	Logger() mlog.LoggerIFace
	Context() context.Context
	WithT(i18n.TranslateFunc) CTX
	WithSession(s *model.Session) CTX
	WithRequestId(string) CTX
	WithIPAddress(string) CTX
	WithXForwardedFor(string) CTX
	WithPath(string) CTX
	WithUserAgent(string) CTX
	WithAcceptLanguage(string) CTX
	WithLogger(mlog.LoggerIFace) CTX
	WithContext(ctx context.Context) CTX
	With(func(ctx CTX) CTX) CTX
}

CTX should be abbreviated as `rctx`.

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context should be abbreviated as `rctx`.

func EmptyContext

func EmptyContext(logger mlog.LoggerIFace) *Context

func NewContext

func NewContext(ctx context.Context, requestId, ipAddress, xForwardedFor, path, userAgent, acceptLanguage string, t i18n.TranslateFunc) *Context

func TestContext added in v0.0.10

func TestContext(t testing.TB) *Context

TestContext creates an empty context with a new logger to use in testing where a test helper is not required.

func (*Context) AcceptLanguage

func (c *Context) AcceptLanguage() string

func (*Context) Context

func (c *Context) Context() context.Context

func (*Context) GetT

func (c *Context) GetT() i18n.TranslateFunc

func (*Context) IPAddress

func (c *Context) IPAddress() string

func (*Context) Logger

func (c *Context) Logger() mlog.LoggerIFace

func (*Context) Path

func (c *Context) Path() string

func (*Context) RequestId

func (c *Context) RequestId() string

func (*Context) Session

func (c *Context) Session() *model.Session

func (*Context) T

func (c *Context) T(translationID string, args ...any) string

func (*Context) UserAgent

func (c *Context) UserAgent() string

func (*Context) With added in v0.0.10

func (c *Context) With(f func(ctx CTX) CTX) CTX

func (*Context) WithAcceptLanguage added in v0.0.10

func (c *Context) WithAcceptLanguage(s string) CTX

func (*Context) WithContext added in v0.0.10

func (c *Context) WithContext(ctx context.Context) CTX

func (*Context) WithIPAddress added in v0.0.10

func (c *Context) WithIPAddress(s string) CTX

func (*Context) WithLogger added in v0.0.10

func (c *Context) WithLogger(logger mlog.LoggerIFace) CTX

func (*Context) WithPath added in v0.0.10

func (c *Context) WithPath(s string) CTX

func (*Context) WithRequestId added in v0.0.10

func (c *Context) WithRequestId(s string) CTX

func (*Context) WithSession added in v0.0.10

func (c *Context) WithSession(s *model.Session) CTX

func (*Context) WithT added in v0.0.10

func (c *Context) WithT(t i18n.TranslateFunc) CTX

func (*Context) WithUserAgent added in v0.0.10

func (c *Context) WithUserAgent(s string) CTX

func (*Context) WithXForwardedFor added in v0.0.10

func (c *Context) WithXForwardedFor(s string) CTX

func (*Context) XForwardedFor

func (c *Context) XForwardedFor() string

Jump to

Keyboard shortcuts

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