add exported fields' comments
This commit is contained in:
parent
104111b02e
commit
d590d31327
|
@ -18,7 +18,7 @@ func (m *Method) CheckScope(scope middleware.Scope) bool {
|
|||
|
||||
for _, AND := range OR {
|
||||
|
||||
if !isPermInScope(AND, scope) {
|
||||
if !scopeHasPermission(AND, scope) {
|
||||
granted = false
|
||||
break
|
||||
}
|
||||
|
@ -35,8 +35,8 @@ func (m *Method) CheckScope(scope middleware.Scope) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// Returns whether @perm is present in @scope
|
||||
func isPermInScope(perm string, scope []string) bool {
|
||||
// scopeHasPermission returns whether @perm is present in a given @scope
|
||||
func scopeHasPermission(perm string, scope []string) bool {
|
||||
for _, s := range scope {
|
||||
if perm == s {
|
||||
return true
|
||||
|
|
|
@ -2,7 +2,7 @@ package api
|
|||
|
||||
/* (1) Configuration
|
||||
---------------------------------------------------------*/
|
||||
|
||||
// Parameter represents a parameter definition (from api.json)
|
||||
type Parameter struct {
|
||||
Description string `json:"info"`
|
||||
Type string `json:"type"`
|
||||
|
@ -10,6 +10,8 @@ type Parameter struct {
|
|||
Optional bool
|
||||
Default *interface{} `json:"default"`
|
||||
}
|
||||
|
||||
// Method represents a method definition (from api.json)
|
||||
type Method struct {
|
||||
Description string `json:"info"`
|
||||
Permission [][]string `json:"scope"`
|
||||
|
@ -17,6 +19,7 @@ type Method struct {
|
|||
Download *bool `json:"download"`
|
||||
}
|
||||
|
||||
// Controller represents a controller definition (from api.json)
|
||||
type Controller struct {
|
||||
GET *Method `json:"GET"`
|
||||
POST *Method `json:"POST"`
|
||||
|
|
|
@ -5,7 +5,10 @@ import (
|
|||
"git.xdrm.io/go/aicra/driver"
|
||||
)
|
||||
|
||||
// ErrNoMatchingType is returned when the Match() method does not find any type checker
|
||||
var ErrNoMatchingType = errors.New("no matching type")
|
||||
|
||||
// ErrDoesNotMatch is returned when the Check() method fails (invalid type value)
|
||||
var ErrDoesNotMatch = errors.New("does not match")
|
||||
|
||||
// CreateRegistry creates an empty type registry
|
||||
|
|
|
@ -4,7 +4,11 @@ import (
|
|||
"errors"
|
||||
)
|
||||
|
||||
// ErrUnknownKey is returned when a key does not exist using a getter
|
||||
var ErrUnknownKey = errors.New("key does not exist")
|
||||
|
||||
// ErrInvalidType is returned when a typed getter tries to get a value that cannot be
|
||||
// translated into the requested type
|
||||
var ErrInvalidType = errors.New("invalid type")
|
||||
|
||||
// Has checks whether a key exists in the arguments
|
||||
|
|
Loading…
Reference in New Issue