From ddbdbabe48dcc9c0bc0643da52f826b6a9f7b985 Mon Sep 17 00:00:00 2001 From: George Shaw Date: Mon, 6 Nov 2017 11:54:12 -0600 Subject: [PATCH] referencing issue #59 --- pkg/api/README.md | 24 ++------------------- pkg/api/api_handler.go | 6 +++--- pkg/api/user/README.md | 39 +++++++++++++++++++++++++++++++++++ pkg/webhost/authentication.go | 6 +++--- 4 files changed, 47 insertions(+), 28 deletions(-) create mode 100644 pkg/api/user/README.md diff --git a/pkg/api/README.md b/pkg/api/README.md index 729c649..e7633c0 100644 --- a/pkg/api/README.md +++ b/pkg/api/README.md @@ -1,23 +1,3 @@ -# Working API Calls +# API Documentation -```go -// User Authentication API - pkg/api/user_auth.go -/* -JSON Data Required: - { - "user": "test", - "pass": "test", - } -*/ -func UserAuthentication(res http.ResponseWriter, req *http.Request) bool - -// User Registration API - pkg/api/user_auth.go -/* -JSON Data Required: - { - "user": "test", - "pass": "test", - } -*/ -func UserRegistration(res http.ResponseWriter, req *http.Request) bool -``` +Navigate inside of the folders of this package to see specific documentation on the various available APIs. diff --git a/pkg/api/api_handler.go b/pkg/api/api_handler.go index aed1a24..99ea2fc 100644 --- a/pkg/api/api_handler.go +++ b/pkg/api/api_handler.go @@ -16,11 +16,11 @@ func HandleAPI(path string, res http.ResponseWriter, req *http.Request) (bool, b suspectApi := strings.ToLower(splitUrl[len(splitUrl)-1]) switch suspectApi { - case "user_auth": + case "api/user/auth": return true, user.Auth(res, req) - case "user_register": + case "api/user/register": return true, user.Register(res, req) - case "user_logout": + case "api/user/logout": return true, user.Logout(res, req) default: return false, false diff --git a/pkg/api/user/README.md b/pkg/api/user/README.md new file mode 100644 index 0000000..a1f74ef --- /dev/null +++ b/pkg/api/user/README.md @@ -0,0 +1,39 @@ +# User API Documentation + +```go +/* +Relative API Path: + api/user/auth +Request: + { + "user": "test", + "pass": "test", + } +Response(204, 400, 401, 405, 500): + N/A +*/ +func UserAuthentication(res http.ResponseWriter, req *http.Request) bool + +/* +Relative API Path: + api/user/register +Request: + { + "user": "test", + "pass": "test", + } +Response (204, 400, 405, 500): + N/A +*/ +func UserRegistration(res http.ResponseWriter, req *http.Request) bool + +/* +Relative API Path: + api/user/logout +Request: + N/A +Response (204, 405, 500): + N/A +*/ +func UserLogout(res http.ResponseWriter, req *http.Request) bool +``` diff --git a/pkg/webhost/authentication.go b/pkg/webhost/authentication.go index 8af16f3..f126339 100644 --- a/pkg/webhost/authentication.go +++ b/pkg/webhost/authentication.go @@ -23,9 +23,9 @@ func reqAuth(path string) bool { dismissibleFiles := []string{ "index.html", - "user_auth", - "user_register", - "user_logout", + "api/user/auth", + "api/user/register", + "api/user/logout", } for _, f := range dismissibleFiles { if strings.HasSuffix(path, f) {