2016-10-02 03:18:41 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2016-12-24 09:28:34 +00:00
|
|
|
"encoding/json"
|
|
|
|
"net/http"
|
|
|
|
"os"
|
2016-10-02 03:18:41 +01:00
|
|
|
)
|
|
|
|
|
2016-12-24 09:28:34 +00:00
|
|
|
type TestJSONResponse struct {
|
|
|
|
Test bool
|
|
|
|
}
|
|
|
|
|
2016-10-02 03:18:41 +01:00
|
|
|
func handler(w http.ResponseWriter, r *http.Request) {
|
2016-12-24 09:28:34 +00:00
|
|
|
response := TestJSONResponse{true}
|
|
|
|
|
|
|
|
js, err := json.Marshal(response)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
|
|
w.Write(js)
|
2016-10-02 03:18:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2016-12-24 09:28:34 +00:00
|
|
|
http.HandleFunc("/", handler)
|
|
|
|
http.ListenAndServe(":"+os.Args[1], nil)
|
2016-10-02 03:18:41 +01:00
|
|
|
}
|