From ee82f48adac5c0bf8597a02cd247a77fb00c7d0c Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sat, 7 Jul 2018 23:09:19 +0200 Subject: [PATCH] update --- .gitignore | 3 ++- cmd/test/main.go | 4 ++-- middleware/1-auth/main.go | 11 +++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 middleware/1-auth/main.go diff --git a/.gitignore b/.gitignore index f1fe8d1..d7a1847 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -*.so \ No newline at end of file +*.so +.build \ No newline at end of file diff --git a/cmd/test/main.go b/cmd/test/main.go index 88c8b50..7677cb2 100644 --- a/cmd/test/main.go +++ b/cmd/test/main.go @@ -7,14 +7,14 @@ import ( func main() { - srv, err := aicra.Init("manifest.json") + server, err := aicra.New("manifest.json") if err != nil { log.Fatal("cannot load config", err) } log.Printf("[Server up] 0.0.0.0:4242\n") - err = srv.Launch(4242) + err = server.Listen(4242) if err != nil { log.Fatalf("*** server failed (%s)\n", err) } diff --git a/middleware/1-auth/main.go b/middleware/1-auth/main.go new file mode 100644 index 0000000..a177db9 --- /dev/null +++ b/middleware/1-auth/main.go @@ -0,0 +1,11 @@ +package main + +import ( + "git.xdrm.io/go/aicra/middleware" + "net/http" +) + +// Authentication middleware +func Inspect(req http.Request, scope middleware.Scope){ + scope = append(scope, "user"); +}