add exported fields' comments

This commit is contained in:
Adrien Marquès 2018-10-07 11:14:04 +02:00
parent 104111b02e
commit d590d31327
4 changed files with 14 additions and 4 deletions

View File

@ -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

View File

@ -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"`

View File

@ -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

View File

@ -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