Created
February 16, 2019 18:23
-
-
Save masnun/f3e2ec1dd8ca963f4671fe21e02c1dca to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ( | |
"encoding/json" | |
"net/http" | |
"github.com/go-chi/chi" | |
) | |
func main() { | |
router := chi.NewRouter() | |
router.Get("/", func(writer http.ResponseWriter, request *http.Request) { | |
writer.Header().Set("Content-type", "application/json") | |
writer.WriteHeader(http.StatusOK) | |
json.NewEncoder(writer).Encode(map[string]string{ | |
"message": "hello world!", | |
}) | |
}) | |
http.ListenAndServe(":3000", router) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment