utils

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultHTTPClient = &http.Client{
		Timeout: time.Duration(30 * time.Second),
	}
)

Functions

func Contains

func Contains(list []string, needle string) bool

func DecryptAES

func DecryptAES(data string, key string) (string, error)

func DecryptBytesAES

func DecryptBytesAES(cipherText []byte, key string) ([]byte, error)

func EncryptAES

func EncryptAES(data string, key string) (string, error)

func EncryptBytesAES

func EncryptBytesAES(plainText []byte, key string) ([]byte, error)

func FormRequest

func FormRequest(endpoint string, request interface{}) (*http.Request, error)

func GetHashAlgorithm

func GetHashAlgorithm(sigAlgorithm jose.SignatureAlgorithm) (hash.Hash, error)

func HashString

func HashString(hash hash.Hash, s string) string

func HttpRequest

func HttpRequest(client *http.Client, req *http.Request, response interface{}) error

func MarshalJSON

func MarshalJSON(w http.ResponseWriter, i interface{})

func URLEncodeResponse

func URLEncodeResponse(resp interface{}, encoder *schema.Encoder) (string, error)

Types

type CookieHandler

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

func NewCookieHandler

func NewCookieHandler(hashKey, encryptKey []byte, opts ...CookieHandlerOpt) *CookieHandler

func (*CookieHandler) CheckCookie

func (c *CookieHandler) CheckCookie(r *http.Request, name string) (string, error)

func (*CookieHandler) CheckQueryCookie

func (c *CookieHandler) CheckQueryCookie(r *http.Request, name string) (string, error)

func (*CookieHandler) DeleteCookie

func (c *CookieHandler) DeleteCookie(w http.ResponseWriter, name string)

func (*CookieHandler) SetCookie

func (c *CookieHandler) SetCookie(w http.ResponseWriter, name, value string) error

type CookieHandlerOpt

type CookieHandlerOpt func(*CookieHandler)

func WithDomain

func WithDomain(domain string) CookieHandlerOpt

func WithMaxAge

func WithMaxAge(maxAge int) CookieHandlerOpt

func WithSameSite

func WithSameSite(sameSite http.SameSite) CookieHandlerOpt

func WithUnsecure

func WithUnsecure() CookieHandlerOpt

Jump to

Keyboard shortcuts

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