fix middleware + add example for manifest scope
This commit is contained in:
parent
ee82f48ada
commit
d5b9567663
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
"POST": {
|
"POST": {
|
||||||
"info": "creates a new tiny url",
|
"info": "creates a new tiny url",
|
||||||
"scope": [[]],
|
"scope": [["admin"]],
|
||||||
"in": {
|
"in": {
|
||||||
"URL#0": { "info": "preferred tiny url", "type": "varchar(1,30)", "name": "url" },
|
"URL#0": { "info": "preferred tiny url", "type": "varchar(1,30)", "name": "url" },
|
||||||
"target": { "info": "url to shorten", "type": "varchar(5,300)" }
|
"target": { "info": "url to shorten", "type": "varchar(5,300)" }
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
"PUT": {
|
"PUT": {
|
||||||
"info": "overrides an existing tiny url",
|
"info": "overrides an existing tiny url",
|
||||||
"scope": [[]],
|
"scope": [["admin"]],
|
||||||
"in": {
|
"in": {
|
||||||
"URL#0": { "info": "preferred tiny url", "type": "varchar(1,30)", "name": "url" },
|
"URL#0": { "info": "preferred tiny url", "type": "varchar(1,30)", "name": "url" },
|
||||||
"target": { "info": "url to shorten", "type": "varchar(5,300)" }
|
"target": { "info": "url to shorten", "type": "varchar(5,300)" }
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
"DELETE": {
|
"DELETE": {
|
||||||
"info": "removes an existing tiny url",
|
"info": "removes an existing tiny url",
|
||||||
"scope": [[]],
|
"scope": [["admin"]],
|
||||||
"in": {
|
"in": {
|
||||||
"URL#0": { "info": "preferred tiny url", "type": "varchar(1,30)", "name": "url" }
|
"URL#0": { "info": "preferred tiny url", "type": "varchar(1,30)", "name": "url" }
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,6 +6,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Authentication middleware
|
// Authentication middleware
|
||||||
func Inspect(req http.Request, scope middleware.Scope){
|
func Inspect(req http.Request, scope *middleware.Scope) {
|
||||||
scope = append(scope, "user");
|
*scope = append(*scope, "admin")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue