Skip to content

Instantly share code, notes, and snippets.

@AdamHepner
Created January 17, 2019 20:22
Show Gist options
  • Save AdamHepner/03b9addac10c47534bd3392cb0e069e1 to your computer and use it in GitHub Desktop.
Save AdamHepner/03b9addac10c47534bd3392cb0e069e1 to your computer and use it in GitHub Desktop.
package main
import (
"log"
"net/http"
"github.com/go-chi/chi/middleware"
"github.com/go-chi/chi"
"github.com/go-chi/render"
)
func main() {
router := chi.NewRouter()
router.Use(middleware.DefaultCompress)
router.Get("/", func(w http.ResponseWriter, r *http.Request) {
render.Status(r, http.StatusTeapot)
render.JSON(w, r, "This is it boys")
})
log.Fatal(http.ListenAndServe(":8081", router))
}
@AdamHepner
Copy link
Author

Expected behaviour when GETting http://localhost:8081/ is to get a HTTP status 418 "I'm a teapot". Unfortunately the line 15 causes Chi to overwrite the status with 200.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment