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)
pull/24/head
Jordan Wright 2013-12-07 15:08:09 -06:00
parent a3518032be
commit ceaf400206
4 changed files with 26 additions and 10 deletions

9
api.go
View File

@ -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"]+"}")
}

View File

@ -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/")))

View File

@ -64,4 +64,7 @@ footer > p {
.header {
margin-top:10px;
}
.sidebar {
padding-left:0px;
}

View File

@ -6,9 +6,24 @@
</h1>
</div>
</div>
<div class="container">
<div class="col-md-3 sidebar">
<ul class="nav nav-pills nav-stacked">
<li class="active"><a href="#">Dashboard</a>
</li>
<li><a href="/users">Users &amp; Groups</a>
</li>
<li><a href="/settings">Settings</a>
</li>
</ul>
</div>
<div class="col-md-9">
Testing
</div>
</div>
<div class="container">
<hr>
<footer>
<footer>
<p>&copy; Jordan (jordan-wright) 2013</p>
</footer>
</div>