util

package
v1.0.8-fixed Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResponseCode = "response_code"
)

Variables

View Source
var Logger *wrapper.Log

Functions

func IsEndpointAllowed

func IsEndpointAllowed(endpoint *url.URL, allowedDomains []string) bool

IsEndpointAllowed checks whether the endpoint URL is allowed based on an allowed domains list.

func SendError

func SendError(errMsg string, rw http.ResponseWriter, status int)

func SplitHostPort

func SplitHostPort(hostport string) (host, port string)

SplitHostPort separates host and port. If the port is not valid, it returns the entire input as host, and it doesn't check the validity of the host. Unlike net.SplitHostPort, but per RFC 3986, it requires ports to be numeric. *** taken from net/url, modified validOptionalPort() to accept ":*"

Types

type Function

type Function func(args ...interface{})

定义一个泛型 Function 类型,它接受任意数量的任意类型的参数

func Combine

func Combine(functions ...Function) Function

type ResponseRecorder

type ResponseRecorder struct {
	HeaderMap http.Header
	Code      int
}

func NewRecorder

func NewRecorder() *ResponseRecorder

NewRecorder returns an initialized ResponseRecorder.

func (*ResponseRecorder) GetStatus

func (rw *ResponseRecorder) GetStatus() int

func (*ResponseRecorder) Header

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

func (*ResponseRecorder) Write

func (rw *ResponseRecorder) Write(buf []byte) (int, error)

func (*ResponseRecorder) WriteHeader

func (rw *ResponseRecorder) WriteHeader(code int)

WriteHeader implements http.ResponseWriter.

type Token

type Token struct {
	AccessToken  string
	TokenType    string
	RefreshToken string
	Expiry       time.Time
	Raw          interface{}
}

func UnmarshalToken

func UnmarshalToken(Headers http.Header, body []byte) (*Token, error)

func (*Token) Extra

func (t *Token) Extra(key string) interface{}

Jump to

Keyboard shortcuts

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