Browse Source

Add redirect from home route

gRPC
garritfra 6 years ago
parent
commit
de21289c7c
  1. 5
      core/Server.go

5
core/Server.go

@ -23,6 +23,7 @@ func StartServer() {
blockchain.AddBlock(block)
http.HandleFunc("/", redirect)
http.HandleFunc("/blockchain", listBlocks)
if err := http.ListenAndServe(":8080", nil); err != nil {
@ -30,6 +31,10 @@ func StartServer() {
}
}
func redirect(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/blockchain", 301)
}
func listBlocks(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(blockchain.blocks)
}

Loading…
Cancel
Save