From 06aaed8237c9f2c720fd837fbff33a3625893e2a Mon Sep 17 00:00:00 2001 From: Settel Date: Mon, 2 Aug 2021 09:52:47 +0200 Subject: [PATCH] /api/userinfo (WIP) --- client/dist/index.html | 2 +- server/src/handler/internal.go | 4 ---- server/src/handler/userinfo.go | 12 ++++++++++++ server/src/knyt.go | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 server/src/handler/userinfo.go diff --git a/client/dist/index.html b/client/dist/index.html index 381b1a5..8ed7385 100644 --- a/client/dist/index.html +++ b/client/dist/index.html @@ -7,7 +7,7 @@

KnYC

- /private/ + /api/userinfo

diff --git a/server/src/handler/internal.go b/server/src/handler/internal.go index 6a59abe..0637f66 100644 --- a/server/src/handler/internal.go +++ b/server/src/handler/internal.go @@ -17,7 +17,3 @@ func CreateVersionHandler() HandlerFunc { fmt.Fprintf(w, "%d\n", startTime) } } - -func IsLoggedIn(w http.ResponseWriter, _ *http.Request) { - fmt.Fprintf(w, "ok") -} diff --git a/server/src/handler/userinfo.go b/server/src/handler/userinfo.go new file mode 100644 index 0000000..c88bb9b --- /dev/null +++ b/server/src/handler/userinfo.go @@ -0,0 +1,12 @@ +package handler + +import ( + "fmt" + "net/http" +) + +func GetUserInfo(w http.ResponseWriter, r *http.Request) { + w.Header().Add("Content-Type", "application/json") + jsonString := "{}" + fmt.Fprintf(w, string(jsonString)) +} diff --git a/server/src/knyt.go b/server/src/knyt.go index 0c534d5..27c6991 100644 --- a/server/src/knyt.go +++ b/server/src/knyt.go @@ -19,10 +19,10 @@ func main() { mux := handler.NewAuthMux(app) mux.PublicHandleFunc("/__intern__/exit", handler.Exit) + mux.PrivateHandleFunc("/api/userinfo", handler.GetUserInfo) // default handler fsHandler := http.FileServer(http.Dir("../../client/dist/")) - mux.PrivateHandle("/private/", fsHandler) mux.PublicHandle("/", fsHandler) // start listening