20 lines
394 B
Go
20 lines
394 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
func main() {
|
|
mux := http.NewServeMux()
|
|
|
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
|
w.Write([]byte("Hello, World!"))
|
|
})
|
|
mux.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) {
|
|
json.NewEncoder(w).Encode(map[string]string{"message": "Hello, World!"})
|
|
})
|
|
|
|
http.ListenAndServe(":8080", mux)
|
|
}
|