types

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 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

func ToValue

func ToValue(rt *goja.Runtime, v any) goja.Value

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) Params

func (modCtx *ModuleContext) Params() 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 {
	Body          io.ReadCloser
	Method        string
	URL           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) GetBody

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

type ResponseWrapper

type ResponseWrapper struct {
	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) GetBody

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

func (*ResponseWrapper) GetJson

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

func (*ResponseWrapper) Header

func (rw *ResponseWrapper) Header() http.Header

func (*ResponseWrapper) Query

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

func (*ResponseWrapper) SetBody

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

func (*ResponseWrapper) SetJson

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

func (*ResponseWrapper) SetRedirect

func (rw *ResponseWrapper) SetRedirect(url string)

func (*ResponseWrapper) SetRedirectPermanent

func (rw *ResponseWrapper) SetRedirectPermanent(url string)

func (*ResponseWrapper) SetStatus

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

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() []*http.Cookie

func (*ResponseWriterWrapper) End

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

End sends the response.

func (*ResponseWriterWrapper) Header

func (g *ResponseWriterWrapper) Header() http.Header

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) SetCookie

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

func (*ResponseWriterWrapper) Status

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

type Symbolic

type Symbolic interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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