From d30dee5013a946d0ce8d910261339a92fa7a23b5 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Fri, 28 Sep 2018 16:06:20 +0200 Subject: [PATCH] update according to go/aicra release 0.1.1 --- controller/ROOT/main.go | 17 +++++++++++++---- controller/token/main.go | 5 ++++- main.go | 5 +++-- middleware/1-auth/main.go | 3 +-- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/controller/ROOT/main.go b/controller/ROOT/main.go index 97fb347..92c0975 100644 --- a/controller/ROOT/main.go +++ b/controller/ROOT/main.go @@ -3,11 +3,14 @@ package main import ( "git.xdrm.io/example/aicra/db" e "git.xdrm.io/go/aicra/err" + "git.xdrm.io/go/aicra/response" i "git.xdrm.io/go/aicra/response" ) // Redirects to an url from a key -func Get(d i.Arguments, r *i.Response) i.Response { +func Get(d i.Arguments) i.Response { + + r := response.New() /* (1) Init redis connection */ cli := db.Connect() @@ -39,7 +42,9 @@ func Get(d i.Arguments, r *i.Response) i.Response { } // Stores a new tinyurl/fullurl combination -func Post(d i.Arguments, r *i.Response) i.Response { +func Post(d i.Arguments) i.Response { + + r := response.New() /* (1) Init redis connection */ cli := db.Connect() if cli == nil { @@ -73,7 +78,9 @@ func Post(d i.Arguments, r *i.Response) i.Response { } // Overrides a existing tinyurl with new target -func Put(d i.Arguments, r *i.Response) i.Response { +func Put(d i.Arguments) i.Response { + + r := response.New() /* (1) Init redis connection */ cli := db.Connect() @@ -108,7 +115,9 @@ func Put(d i.Arguments, r *i.Response) i.Response { } // Deletes an existing tinyurl -func Delete(d i.Arguments, r *i.Response) i.Response { +func Delete(d i.Arguments) i.Response { + + r := response.New() /* (1) Init redis connection */ cli := db.Connect() diff --git a/controller/token/main.go b/controller/token/main.go index e6e70bd..5dfdb5b 100644 --- a/controller/token/main.go +++ b/controller/token/main.go @@ -5,13 +5,16 @@ import ( "encoding/hex" "git.xdrm.io/example/aicra/db" e "git.xdrm.io/go/aicra/err" + "git.xdrm.io/go/aicra/response" i "git.xdrm.io/go/aicra/response" "strconv" "time" ) // Builds an access token from credentials -func Post(d i.Arguments, r *i.Response) i.Response { +func Post(d i.Arguments) i.Response { + + r := response.New() /* (1) Init redis connection */ cli := db.Connect() diff --git a/main.go b/main.go index ab29e90..2b31422 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "git.xdrm.io/go/aicra" + "git.xdrm.io/go/aicra/driver" "log" "net/http" ) @@ -10,9 +11,9 @@ func main() { listen_addr := "127.0.0.1:4242" - server, err := aicra.New("manifest.json") + server, err := aicra.New("manifest.json", new(driver.Plugin)) if err != nil { - panic("cannot load config") + panic(err) } log.Printf("[Server up] %s\n", listen_addr) diff --git a/middleware/1-auth/main.go b/middleware/1-auth/main.go index 609562f..7a58ce5 100644 --- a/middleware/1-auth/main.go +++ b/middleware/1-auth/main.go @@ -2,13 +2,12 @@ package main import ( "git.xdrm.io/example/aicra/db" - "git.xdrm.io/go/aicra/middleware" "net/http" "strings" ) // Authentication middleware -func Inspect(req http.Request, scope *middleware.Scope) { +func Inspect(req http.Request, scope *[]string) { // 1. get authorization header token := req.Header.Get("Authorization")