socialnetworknews-api

git clone git://archive.git.mtrnord.blog/SocialNetworkNews/socialnetworknews-api.git
Log | Files | Refs | LICENSE

commit c5f3f3f06e48eb7be756ad456c8d2dc9c1315d63
parent 09ff06c821d7546e3f11254adcd76fea786344be
Author: MTRNord <mtrnord1@gmail.com>
Date:   Tue, 10 Apr 2018 21:53:14 +0200

Make ApiVersion a const for easier upping on releases

Diffstat:
Mapi/login/twitter.go | 4+++-
Aapi/util/vars.go | 3+++
Mapi/webserver.go | 7++++---
3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/api/login/twitter.go b/api/login/twitter.go @@ -3,6 +3,7 @@ package login import ( "encoding/json" "fmt" + "github.com/SocialNetworkNews/SocialNetworkNews_API/api/util" "github.com/SocialNetworkNews/SocialNetworkNews_API/db" "github.com/dghubble/gologin" libLogin "github.com/dghubble/gologin/oauth1" @@ -149,7 +150,7 @@ func IssueSession() http.Handler { return } w.Header().Set("UUID", uuidS) - w.Header().Set("API-VERSION", "0.0.0") + w.Header().Set("API-VERSION", util.APIVersion) domain := req.Host log.Println("domain:", domain) w.WriteHeader(http.StatusOK) @@ -175,6 +176,7 @@ func IsAuthenticated(req *http.Request) bool { // IsAuthenticatedHandleFunc returns 200 if the user has a signed session cookie. func IsAuthenticatedHandleFunc(w http.ResponseWriter, req *http.Request) { + w.Header().Set("API-VERSION", util.APIVersion) if IsAuthenticated(req) { Reqsession, err := sessionStore.Get(req, sessionName) if err != nil { diff --git a/api/util/vars.go b/api/util/vars.go @@ -0,0 +1,3 @@ +package util + +const APIVersion = "0.0.0" diff --git a/api/webserver.go b/api/webserver.go @@ -4,6 +4,7 @@ import ( "encoding/csv" "encoding/json" "fmt" + "github.com/SocialNetworkNews/SocialNetworkNews_API/api/util" "github.com/SocialNetworkNews/SocialNetworkNews_API/config" "github.com/SocialNetworkNews/SocialNetworkNews_API/db" "github.com/SocialNetworkNews/SocialNetworkNews_API/twitter" @@ -49,7 +50,7 @@ func Yesterday(w http.ResponseWriter, r *http.Request) { } } w.Header().Set("Content-Type", "application/json") - w.Header().Set("API-VERSION", "0.0.0") + w.Header().Set("API-VERSION", util.APIVersion) w.WriteHeader(http.StatusOK) w.Write(tweets) } @@ -102,7 +103,7 @@ func Papers(w http.ResponseWriter, r *http.Request) { data = papers } w.Header().Set("Content-Type", "application/json") - w.Header().Set("API-VERSION", "0.0.0") + w.Header().Set("API-VERSION", util.APIVersion) w.WriteHeader(http.StatusOK) w.Write(data) } @@ -123,7 +124,7 @@ func PaperFunc(w http.ResponseWriter, r *http.Request) { data = papers } w.Header().Set("Content-Type", "application/json") - w.Header().Set("API-VERSION", "0.0.0") + w.Header().Set("API-VERSION", util.APIVersion) w.WriteHeader(http.StatusOK) w.Write(data) }