From ceaf40020691637dbe45e52a35321e7286001274 Mon Sep 17 00:00:00 2001 From: Jordan Wright Date: Sat, 7 Dec 2013 15:08:09 -0600 Subject: [PATCH] Changed API_Campaigns_Id to be one method Added secure cookie random []byte generation Changed sidebar css Fixed footer alignment (may consider making separate template) --- api.go | 9 ++------- route.go | 7 +++++-- static/css/main.css | 3 +++ templates/dashboard.html | 17 ++++++++++++++++- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/api.go b/api.go index 17326f6a..a2c3b86e 100644 --- a/api.go +++ b/api.go @@ -14,13 +14,8 @@ func API_Campaigns(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello api") } -func API_Campaigns_Id_Post(w http.ResponseWriter, r *http.Request) { +func API_Campaigns_Id(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") vars := mux.Vars(r) - fmt.Fprintf(w, "{\"id\" : "+vars["id"]+"}") -} -func API_Campaigns_Id_Get(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - vars := mux.Vars(r) - fmt.Fprintf(w, "{\"id\" : "+vars["id"]+"}") + fmt.Fprintf(w, "{\"method\" : \""+r.Method+"\", \"id\" : "+vars["id"]+"}") } diff --git a/route.go b/route.go index 53e9676b..8fb15afe 100644 --- a/route.go +++ b/route.go @@ -28,10 +28,14 @@ THE SOFTWARE. import ( "github.com/gorilla/mux" + "github.com/gorilla/securecookie" + "github.com/gorilla/sessions" "html/template" "net/http" ) +var store = sessions.NewCookieStore([]byte(securecookie.GenerateRandomKey(64))) + func createRouter() http.Handler { router := mux.NewRouter() // Base Front-end routes @@ -44,8 +48,7 @@ func createRouter() http.Handler { api := router.PathPrefix("/api").Subrouter() api.HandleFunc("/", API) api.HandleFunc("/campaigns", API_Campaigns) - api.HandleFunc("/campaigns/{id}", API_Campaigns_Id_Post).Methods("POST") - api.HandleFunc("/campaigns/{id}", API_Campaigns_Id_Get).Methods("GET") + api.HandleFunc("/campaigns/{id}", API_Campaigns_Id) //Setup static file serving router.PathPrefix("/").Handler(http.FileServer(http.Dir("./static/"))) diff --git a/static/css/main.css b/static/css/main.css index 06334129..eb174a0e 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -64,4 +64,7 @@ footer > p { .header { margin-top:10px; +} +.sidebar { + padding-left:0px; } \ No newline at end of file diff --git a/templates/dashboard.html b/templates/dashboard.html index c6b59225..7b575bf8 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -6,9 +6,24 @@ +
+ +
+ Testing +
+

-