util

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HeaderXAuth ...
	HeaderXAuth = "X-Auth"
	// HeaderAuthorize ...
	HeaderAuthorize = "Authorization"
	// HeaderAuthorizeBearer ...
	HeaderAuthorizeBearer = "Bearer "
	// HeaderAuthorizeOAuth2 ...
	HeaderAuthorizeOAuth2 = "OAuth2 "
)

Variables

View Source
var (
	// Name ...
	Name = "urbs-console"
	// Version ...
	Version = "unknown"
	// BuildTime ...
	BuildTime = "unknown"
	// GitSHA1 ...
	GitSHA1 = "unknown"
)
View Source
var (
	// UserAgent ...
	UserAgent string
)

Functions

func DigInvoke

func DigInvoke(function interface{}, opts ...dig.InvokeOption) error

DigInvoke ...

func DigProvide

func DigProvide(constructor interface{}, opts ...dig.ProvideOption) error

DigProvide ...

func ExtractBearerToken added in v1.0.0

func ExtractBearerToken(ctx *gear.Context) (token string)

ExtractBearerToken ...

func ExtractToken added in v1.0.0

func ExtractToken(ctx *gear.Context) (token string)

ExtractToken ...

func GetStaticFilePath added in v0.4.0

func GetStaticFilePath() string

GetStaticFilePath the default path is `./static`

func GetUid added in v0.3.0

func GetUid(ctx context.Context) string

GetUid ...

func GetVersion

func GetVersion() []byte

GetVersion ...

func PathExists added in v0.4.0

func PathExists(path string) bool

PathExists returns whether the given file or directory exists

func PrintVersion

func PrintVersion()

PrintVersion ...

func ReadConfig

func ReadConfig(v interface{}, path ...string)

ReadConfig 指定配置文件并解析; 未指定配置文件则通过环境变量获取

func StringSliceHas added in v0.4.0

func StringSliceHas(list []string, a string) bool

StringSliceHas ...

func XAuthExtractor added in v0.4.0

func XAuthExtractor(ctx *gear.Context) (token string)

XAuthExtractor ...

Types

type HID added in v0.4.0

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

HID 基于 HMAC 算法,将内部 int64 的 ID 与 base64 URL 字符串进行相互转换。API 接口不支持 int64 ID 参数。

func NewHID added in v0.4.0

func NewHID(key []byte) *HID

NewHID 根据给定的秘钥生成 HID 实例。

func (*HID) ToHex added in v0.4.0

func (h *HID) ToHex(i int64) string

ToHex 将内部 ID(大于0的 int64)转换成24位 base64 URL 字符串。 如果输入值 <= 0,则返回空字符串。

func (*HID) ToInt64 added in v0.4.0

func (h *HID) ToInt64(s string) int64

ToInt64 将合法的24位 base64 URL 字符串转换成内部 ID(大于0的 int64)。 如果输入值不合法,则返回0。

type UidKey added in v0.3.0

type UidKey struct{}

UidKey ...

Jump to

Keyboard shortcuts

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