Skip to content

Instantly share code, notes, and snippets.

@masnun
Created February 16, 2019 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masnun/f3e2ec1dd8ca963f4671fe21e02c1dca to your computer and use it in GitHub Desktop.
Save masnun/f3e2ec1dd8ca963f4671fe21e02c1dca to your computer and use it in GitHub Desktop.
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