util

package
v3.2.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2018 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrMsgTemplate = "\033[31m>>> %s\033[0m"
)

Variables

View Source
var (
	ErrAuthFailed        = errors.New("authorize failed")
	ErrAuthNotSupported  = errors.New("entry only works on lain-sso authorization")
	ErrContainerNotfound = errors.New("get data successfully but not found the container")
)

Functions

func AuthAPI

func AuthAPI(accessToken string, g *global.Global) (*sso.User, error)

AuthAPI authorizes whether the client with this token has right to access the API

func AuthContainer

func AuthContainer(token, appName string, g *global.Global) (*sso.User, error)

AuthContainer authorizes whether the client with the token has the right to access the application's container

func GetContainer

func GetContainer(appName, procName, instanceNo string, g *global.Global) (*message.Container, error)

GetContainer get container according to appName, procName and instanceNo

func GetMarshalers

func GetMarshalers(r *http.Request) (Marshaler, Unmarshaler)

func GetSourceIP

func GetSourceIP(r *http.Request) string

func GetValidUT8Length

func GetValidUT8Length(data []byte) int

func GetWidthAndHeight

func GetWidthAndHeight(data []byte) (int, int)

func SendCloseMessage

func SendCloseMessage(conn *websocket.Conn, content []byte, msgMarshaller Marshaler, writeLock *sync.Mutex)

func SendMail

func SendMail(msg []byte, g *global.Global) error

SendMail send mail

Types

type ConsoleAuthConf

type ConsoleAuthConf struct {
	Type string `json:"type"`
	URL  string `json:"url"`
}

type ConsoleAuthResponse

type ConsoleAuthResponse struct {
	Message string      `json:"msg"`
	URL     string      `json:"url"`
	Role    ConsoleRole `json:"role"`
}

type ConsoleRole

type ConsoleRole struct {
	Role string `json:"role"`
}

type Marshaler

type Marshaler func(interface{}) ([]byte, error)

type Unmarshaler

type Unmarshaler func([]byte, interface{}) error

type ViaMethod

type ViaMethod int

Jump to

Keyboard shortcuts

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