types

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetModuleContextNamespace

func GetModuleContextNamespace(modCtx *ModuleContext) *spec.Namespace

func GetModuleContextResponseWriterTracker

func GetModuleContextResponseWriterTracker(modCtx *ModuleContext) spec.ResponseWriterTracker

func GetModuleContextRoute

func GetModuleContextRoute(modCtx *ModuleContext) *spec.Route

func GetModuleContextService

func GetModuleContextService(modCtx *ModuleContext) *spec.Service

Types

type CookieOptions

type CookieOptions struct {
	Domain   string    `json:"domain"`
	Expires  time.Time `json:"expires"`
	HttpOnly bool      `json:"httpOnly"`
	MaxAge   int       `json:"maxAge"`
	Path     string    `json:"path"`
	Priority string    `json:"priority"`
	Secure   bool      `json:"secure"`
	Signed   bool      `json:"signed"`
	SameSite string    `json:"sameSite"`
}

type ModuleContext

type ModuleContext struct {
	ID string `json:"id"`
	// contains filtered or unexported fields
}

func ModuleContextWithError

func ModuleContextWithError(
	modCtx *ModuleContext, err error,
) *ModuleContext

func ModuleContextWithResponse

func ModuleContextWithResponse(
	modCtx *ModuleContext,
	resp *http.Response,
) *ModuleContext

func NewModuleContext

func NewModuleContext(
	loop *eventloop.EventLoop,
	rw http.ResponseWriter,
	req *http.Request,
	route *spec.DGateRoute,
	params map[string]string,
) *ModuleContext

func (*ModuleContext) Get

func (modCtx *ModuleContext) Get(key string) any

func (*ModuleContext) Namespace

func (modCtx *ModuleContext) Namespace() *spec.Namespace

func (*ModuleContext) PathParam added in v0.8.0

func (modCtx *ModuleContext) PathParam(key string) string

func (*ModuleContext) PathParams added in v0.8.0

func (modCtx *ModuleContext) PathParams() map[string]string

func (*ModuleContext) Query

func (modCtx *ModuleContext) Query() url.Values

func (*ModuleContext) Request

func (modCtx *ModuleContext) Request() *RequestWrapper

func (*ModuleContext) Response

func (modCtx *ModuleContext) Response() *ResponseWriterWrapper

func (*ModuleContext) Route

func (modCtx *ModuleContext) Route() *spec.Route

func (*ModuleContext) Service

func (modCtx *ModuleContext) Service() *spec.Service

func (*ModuleContext) Set

func (modCtx *ModuleContext) Set(key string, value any)

func (*ModuleContext) Upstream

func (modCtx *ModuleContext) Upstream() *ResponseWrapper

type RequestWrapper

type RequestWrapper struct {
	Method        string
	Path          string
	Headers       http.Header
	Query         url.Values
	Host          string
	RemoteAddress string
	Proto         string
	ContentLength int64
	// contains filtered or unexported fields
}

func GetModuleContextRequest

func GetModuleContextRequest(modCtx *ModuleContext) *RequestWrapper

func NewRequestWrapper

func NewRequestWrapper(
	req *http.Request,
	loop *eventloop.EventLoop,
) *RequestWrapper

func (*RequestWrapper) ReadBody added in v0.8.0

func (g *RequestWrapper) ReadBody() (*goja.ArrayBuffer, error)

func (*RequestWrapper) ReadJson added in v0.8.0

func (g *RequestWrapper) ReadJson() (any, error)

func (*RequestWrapper) WriteBody added in v0.8.0

func (g *RequestWrapper) WriteBody(data any) error

func (*RequestWrapper) WriteJson added in v0.8.0

func (g *RequestWrapper) WriteJson(data any) error

type ResponseWrapper

type ResponseWrapper struct {
	Headers          http.Header `json:"headers"`
	StatusCode       int         `json:"statusCode"`
	StatusText       string      `json:"statusText"`
	Trailer          http.Header `json:"trailer"`
	Protocol         string      `json:"protocol"`
	Uncompressed     bool        `json:"uncompressed"`
	ContentLength    int64       `json:"contentLength"`
	TransferEncoding []string    `json:"transferEncoding"`
	// contains filtered or unexported fields
}

func GetModuleContextResponse

func GetModuleContextResponse(modCtx *ModuleContext) *ResponseWrapper

func NewResponseWrapper

func NewResponseWrapper(
	resp *http.Response,
	loop *eventloop.EventLoop,
) *ResponseWrapper

func (*ResponseWrapper) Cookie

func (rw *ResponseWrapper) Cookie() []*http.Cookie

func (*ResponseWrapper) Query

func (rw *ResponseWrapper) Query() url.Values

func (*ResponseWrapper) ReadBody added in v0.8.0

func (rw *ResponseWrapper) ReadBody() *goja.Promise

func (*ResponseWrapper) ReadJson added in v0.8.0

func (rw *ResponseWrapper) ReadJson() *goja.Promise

func (*ResponseWrapper) Redirect added in v0.8.0

func (rw *ResponseWrapper) Redirect(url string)

func (*ResponseWrapper) RedirectPermanent added in v0.8.0

func (rw *ResponseWrapper) RedirectPermanent(url string)

func (*ResponseWrapper) Status added in v0.8.0

func (rw *ResponseWrapper) Status(status int) *ResponseWrapper

func (*ResponseWrapper) WriteBody added in v0.8.0

func (rw *ResponseWrapper) WriteBody(data any) error

func (*ResponseWrapper) WriteJson added in v0.8.0

func (rw *ResponseWrapper) WriteJson(data any) error

type ResponseWriterWrapper

type ResponseWriterWrapper struct {
	Headers     http.Header
	HeadersSent bool
	Locals      map[string]any
	// contains filtered or unexported fields
}

func NewResponseWriterWrapper

func NewResponseWriterWrapper(
	rw http.ResponseWriter,
	req *http.Request,
) *ResponseWriterWrapper

func (*ResponseWriterWrapper) Cookie

func (g *ResponseWriterWrapper) Cookie(name string, value string, opts ...*CookieOptions) (*ResponseWriterWrapper, error)

func (*ResponseWriterWrapper) End

func (g *ResponseWriterWrapper) End(data any) error

End sends the response.

func (*ResponseWriterWrapper) GetCookie added in v0.8.0

func (g *ResponseWriterWrapper) GetCookie(name string) *http.Cookie

func (*ResponseWriterWrapper) GetCookies added in v0.8.0

func (g *ResponseWriterWrapper) GetCookies() []*http.Cookie

func (*ResponseWriterWrapper) Json

func (g *ResponseWriterWrapper) Json(data any) error

Json sends a JSON response.

func (*ResponseWriterWrapper) Location

func (*ResponseWriterWrapper) Redirect

func (g *ResponseWriterWrapper) Redirect(url string)

func (*ResponseWriterWrapper) RedirectPermanent

func (g *ResponseWriterWrapper) RedirectPermanent(url string)

func (*ResponseWriterWrapper) Send

func (g *ResponseWriterWrapper) Send(data any) error

func (*ResponseWriterWrapper) Status

func (g *ResponseWriterWrapper) Status(status int) *ResponseWriterWrapper

Jump to

Keyboard shortcuts

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