Last active
October 25, 2015 11:00
-
-
Save alt332/8d0a27a509a89ea298cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"net/http" | |
"encoding/json" | |
"io/ioutil" | |
"log" | |
"fmt" | |
) | |
type data []map[string]string | |
func returnJSON(w http.ResponseWriter, r *http.Request) { | |
jsonFile, _ := ioutil.ReadFile("./data.json") | |
var p data | |
fmt.Println("Starting") | |
_ = json.Unmarshal(jsonFile, &p) | |
w.Header().Set("Content-Type", "application/json") | |
w.Write(jsonFile) | |
} | |
func main() { | |
http.HandleFunc("/", returnJSON) | |
err := http.ListenAndServe(":9090", nil) | |
if err != nil { | |
log.Fatal("ListenAndServe: ", err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment