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 {
|
for _, AND := range OR {
|
||||||
|
|
||||||
if !isPermInScope(AND, scope) {
|
if !scopeHasPermission(AND, scope) {
|
||||||
granted = false
|
granted = false
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,8 @@ func (m *Method) CheckScope(scope middleware.Scope) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns whether @perm is present in @scope
|
// scopeHasPermission returns whether @perm is present in a given @scope
|
||||||
func isPermInScope(perm string, scope []string) bool {
|
func scopeHasPermission(perm string, scope []string) bool {
|
||||||
for _, s := range scope {
|
for _, s := range scope {
|
||||||
if perm == s {
|
if perm == s {
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -2,7 +2,7 @@ package api
|
||||||
|
|
||||||
/* (1) Configuration
|
/* (1) Configuration
|
||||||
---------------------------------------------------------*/
|
---------------------------------------------------------*/
|
||||||
|
// Parameter represents a parameter definition (from api.json)
|
||||||
type Parameter struct {
|
type Parameter struct {
|
||||||
Description string `json:"info"`
|
Description string `json:"info"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
|
@ -10,6 +10,8 @@ type Parameter struct {
|
||||||
Optional bool
|
Optional bool
|
||||||
Default *interface{} `json:"default"`
|
Default *interface{} `json:"default"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Method represents a method definition (from api.json)
|
||||||
type Method struct {
|
type Method struct {
|
||||||
Description string `json:"info"`
|
Description string `json:"info"`
|
||||||
Permission [][]string `json:"scope"`
|
Permission [][]string `json:"scope"`
|
||||||
|
@ -17,6 +19,7 @@ type Method struct {
|
||||||
Download *bool `json:"download"`
|
Download *bool `json:"download"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Controller represents a controller definition (from api.json)
|
||||||
type Controller struct {
|
type Controller struct {
|
||||||
GET *Method `json:"GET"`
|
GET *Method `json:"GET"`
|
||||||
POST *Method `json:"POST"`
|
POST *Method `json:"POST"`
|
||||||
|
|
|
@ -5,7 +5,10 @@ import (
|
||||||
"git.xdrm.io/go/aicra/driver"
|
"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")
|
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")
|
var ErrDoesNotMatch = errors.New("does not match")
|
||||||
|
|
||||||
// CreateRegistry creates an empty type registry
|
// CreateRegistry creates an empty type registry
|
||||||
|
|
|
@ -4,7 +4,11 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ErrUnknownKey is returned when a key does not exist using a getter
|
||||||
var ErrUnknownKey = errors.New("key does not exist")
|
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")
|
var ErrInvalidType = errors.New("invalid type")
|
||||||
|
|
||||||
// Has checks whether a key exists in the arguments
|
// Has checks whether a key exists in the arguments
|
||||||
|
|
Loading…
Reference in New Issue