Help us shape the future of Go! Take the 2026 Go Developer Survey

validator

package
v2.14.5 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchIP

func FetchIP(pair string) string

TODO(rustatian): to sdk/utils

func ServerAccessValidator

func ServerAccessValidator(r *http.Request) ([]byte, error)

func TopicsAccessValidator

func TopicsAccessValidator(r *http.Request, topics ...string) ([]byte, error)

func URI

func URI(r *http.Request) string

URI fetches full uri from request in a form of string (including https scheme if TLS connection is enabled). TODO(rustatian): to sdk/utils

Types

type AccessValidator

type AccessValidator struct {
	Header http.Header `json:"headers"`
	Status int         `json:"status"`
	Body   []byte
}

type AccessValidatorFn

type AccessValidatorFn = func(r *http.Request, channels ...string) (*AccessValidator, error)

type Request

type Request struct {
	// RemoteAddr contains ip address of client, make sure to check X-Real-Ip and X-Forwarded-For for real client address.
	RemoteAddr string `json:"remoteAddr"`

	// Protocol includes HTTP protocol version.
	Protocol string `json:"protocol"`

	// Method contains name of HTTP method used for the request.
	Method string `json:"method"`

	// URI contains full request URI with scheme and query.
	URI string `json:"uri"`

	// Header contains list of request headers.
	Header http.Header `json:"headers"`

	// Cookies contains list of request cookies.
	Cookies map[string]string `json:"cookies"`

	// RawQuery contains non parsed query string (to be parsed on php end).
	RawQuery string `json:"rawQuery"`

	// Parsed indicates that request body has been parsed on RR end.
	Parsed bool `json:"parsed"`

	// Attributes can be set by chained mdwr to safely pass value from Golang to PHP. See: GetAttribute, SetAttribute functions.
	Attributes map[string]interface{} `json:"attributes"`
}

Request maps net/http requests to PSR7 compatible structure and managed state of temporary uploaded files.

Jump to

Keyboard shortcuts

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