|
@@ -71,6 +71,7 @@ func main() {
|
|
http.HandleFunc("/json", jsonHandler)
|
|
http.HandleFunc("/json", jsonHandler)
|
|
http.HandleFunc("/fortune", fortuneHandler)
|
|
http.HandleFunc("/fortune", fortuneHandler)
|
|
http.HandleFunc("/update", updateHandler)
|
|
http.HandleFunc("/update", updateHandler)
|
|
|
|
+ http.HandleFunc("/plaintext", plaintextHandler)
|
|
http.ListenAndServe(":8080", nil)
|
|
http.ListenAndServe(":8080", nil)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -79,6 +80,13 @@ func jsonHandler(w http.ResponseWriter, r *http.Request) {
|
|
json.NewEncoder(w).Encode(&Message{"Hello, world"})
|
|
json.NewEncoder(w).Encode(&Message{"Hello, world"})
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+var HelloWorld = []byte("Hello, World!")
|
|
|
|
+
|
|
|
|
+func plaintextHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
|
+ w.Header().Set("Content-Type", "text/plain")
|
|
|
|
+ w.Write(HelloWorld)
|
|
|
|
+}
|
|
|
|
+
|
|
func worldHandler(w http.ResponseWriter, r *http.Request) {
|
|
func worldHandler(w http.ResponseWriter, r *http.Request) {
|
|
n := 1
|
|
n := 1
|
|
if nStr := r.URL.Query().Get("queries"); len(nStr) != 0 {
|
|
if nStr := r.URL.Query().Get("queries"); len(nStr) != 0 {
|