|
|
|
@ -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) |
|
|
|
|
} |
|
|
|
|