Documentation ¶
Index ¶
- Variables
- func LDAPAuth(username string, password string) error
- func LDAPUserExist(username string) bool
- func NormalizeAddr(addr string) string
- func ReturnBadRequest(w http.ResponseWriter, err error)
- func ReturnByte(w http.ResponseWriter, httpStatus int, msg []byte)
- func ReturnForbidden(w http.ResponseWriter, msg string)
- func ReturnJson(w http.ResponseWriter, httpStatus int, returnJson interface{})
- func ReturnNotFound(w http.ResponseWriter, msg string)
- func ReturnOK(w http.ResponseWriter, msg string)
- func ReturnServerError(w http.ResponseWriter, err error)
- func ReturnUnauthorized(w http.ResponseWriter, msg string)
- type Cluster
- type Response
- type Service
- func (s *Service) Close() error
- func (s *Service) FormRedirect(r *http.Request, host string) string
- func (s *Service) HandlerGroupCreate(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) HandlerGroupGet(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) HandlerGroupList(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) HandlerRemoveGroup(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) HandlerRemoveUser(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) HandlerSignin(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) HandlerSignout(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) HandlerUpdateGroupItem(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) HandlerUpdateGroupMember(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) HandlerUserGet(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) HandlerUserListGet(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) HandlerUserSet(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (s *Service) Start() error
- type UserToken
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidParam = errors.New("invalid infomation")
Functions ¶
func LDAPUserExist ¶
func NormalizeAddr ¶
NormalizeAddr ensures that the given URL has a HTTP protocol prefix. If none is supplied, it prefixes the URL with "http://".
func ReturnBadRequest ¶
func ReturnBadRequest(w http.ResponseWriter, err error)
Return 400 http status.
func ReturnForbidden ¶
func ReturnForbidden(w http.ResponseWriter, msg string)
Return 403 http status.
func ReturnJson ¶
func ReturnJson(w http.ResponseWriter, httpStatus int, returnJson interface{})
func ReturnNotFound ¶
func ReturnNotFound(w http.ResponseWriter, msg string)
Return 404 http status.
func ReturnServerError ¶
func ReturnServerError(w http.ResponseWriter, err error)
Return 500 http status.
func ReturnUnauthorized ¶
func ReturnUnauthorized(w http.ResponseWriter, msg string)
Return 401 http status.
Types ¶
type Cluster ¶
type Cluster interface { // Join joins the node, reachable at addr, to the cluster. Join(addr string) error // Remove removes a node from the store, specified by addr. Remove(addr string) error // Create a bucket, via distributed consensus. CreateBucket(name []byte) error // Create a bucket via distributed consensus if not exist. CreateBucketIfNotExist(name []byte) error // Remove a bucket, via distributed consensus. RemoveBucket(name []byte) error // Get returns the value for the given key. View(bucket, key []byte) ([]byte, error) // ViewPrefix returns the value for the keys has the keyPrefix. ViewPrefix(bucket, keyPrefix []byte) (map[string][]byte, error) // Set sets the value for the given key, via distributed consensus. Update(bucket []byte, key []byte, value []byte) error // RemoveKey removes the key from the bucket. RemoveKey(bucket, key []byte) error // Batch update values for given keys in given buckets, via distributed consensus. Batch(rows []sm.Row) error // GetSession returns the sression value for the given key. GetSession(key interface{}) interface{} // SetSession sets the value for the given key, via distributed consensus. SetSession(key, value interface{}) error // DelSession delete the value for the given key, via distributed consensus. DelSession(key interface{}) error // Backup database. Backup() ([]byte, error) // Restore restores backup data file. Restore(backupfile string) error // Peers return the map of Raft addresses to API addresses. Peers() (map[string]map[string]string, error) // Statistics returns statistics for periodic monitoring. Statistics(tags map[string]string) []sm.Statistic }
Cluster is the interface op must implement.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides HTTP service.
func New ¶
func New(c config.HTTPConfig, cluster Cluster) (*Service, error)
New returns an uninitialized HTTP service.
func (*Service) FormRedirect ¶
FormRedirect returns the value for the "Location" header for a 301 response.
func (*Service) HandlerGroupCreate ¶
func (s *Service) HandlerGroupCreate(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Service) HandlerGroupGet ¶
func (s *Service) HandlerGroupGet(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
HandlerGroupGet handle query group resquest
func (*Service) HandlerGroupList ¶
func (s *Service) HandlerGroupList(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
HandlerGroupGet handle query group list resquest
func (*Service) HandlerRemoveGroup ¶
func (s *Service) HandlerRemoveGroup(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
HandlerRemoveGroup handle remove group request
func (*Service) HandlerRemoveUser ¶
func (s *Service) HandlerRemoveUser(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Service) HandlerSignin ¶
func (s *Service) HandlerSignin(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
SigninHandler handler signin request
func (*Service) HandlerSignout ¶
func (s *Service) HandlerSignout(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
SignoutHandler handler signout request
func (*Service) HandlerUpdateGroupItem ¶
func (s *Service) HandlerUpdateGroupItem(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
HandlerGroupGet handle update group resquest
func (*Service) HandlerUpdateGroupMember ¶
func (s *Service) HandlerUpdateGroupMember(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Service) HandlerUserGet ¶
func (s *Service) HandlerUserGet(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
HandlerGroupGet handle query user resquest
func (*Service) HandlerUserListGet ¶
func (s *Service) HandlerUserListGet(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
HandlerUserListGet handle query user list resquest
func (*Service) HandlerUserSet ¶
func (s *Service) HandlerUserSet(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
HandlerGroupGet handle set user resquest