utils

package
v0.0.0-...-bf87500 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2018 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTP_CONTEXT_KEY_REQUEST = 0x01
)

Variables

This section is empty.

Functions

func GetCookie

func GetCookie(r *http.Request, key string, defaultVal string) string

func GetPost

func GetPost(r *http.Request, key string, defaultVal string) string

func GetQuery

func GetQuery(r *http.Request, key string, defaultVal string) string

func HttpHandlerWrapper

func HttpHandlerWrapper(method interface{}) func(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

func Inject

func Inject(objs ...interface{})

func VerifyLdapConfig

func VerifyLdapConfig(conf *LdapConf) (err error)

Types

type GlobalConfig

type GlobalConfig struct {
	LdapConf   LdapConf   `yaml:"ldap"`
	ServerConf ServerConf `yaml:"http"`
}

func GetConfig

func GetConfig(cfgFile string) *GlobalConfig

GetConfig get cfg

type HttpServer

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

func NewHttpServer

func NewHttpServer(host string) *HttpServer

func (*HttpServer) ANY

func (s *HttpServer) ANY(path string, handle httprouter.Handle)

func (*HttpServer) GET

func (s *HttpServer) GET(path string, handle httprouter.Handle)

func (*HttpServer) POST

func (s *HttpServer) POST(path string, handle httprouter.Handle)

func (*HttpServer) RunHttpServer

func (s *HttpServer) RunHttpServer()

type Ldap

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

func (*Ldap) Auth

func (m *Ldap) Auth(username string, password string) (info *LdapResult, err error)

func (*Ldap) ListUsers

func (m *Ldap) ListUsers() (list []LdapResult, err error)

func (*Ldap) SetLdapConf

func (l *Ldap) SetLdapConf(conf *LdapConf) error

type LdapConf

type LdapConf struct {
	Addr       string   `yaml:"addr"`
	BaseDn     string   `yaml:"base_dn"`
	Filter     string   `yaml:"filter"`
	Attributes []string `yaml:"attributes,flow"`
	BindDn     string   `yaml:"bind_dn"`
	BindPasswd string   `yaml:"bind_passwd"`
}

type LdapResult

type LdapResult struct {
	DN         string
	Attributes map[string][]string
}

type Provider

type Provider interface {
	Provide() []*inject.Object
}

Provider provider interface

type ProviderFunc

type ProviderFunc func() []*inject.Object

ProviderFunc type

func (ProviderFunc) Provide

func (f ProviderFunc) Provide() []*inject.Object

Provide 执行 ProviderFunc 方法

type ServerConf

type ServerConf struct {
	Listen string `yaml:"listen"`
}

Jump to

Keyboard shortcuts

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