List of const content types, because I keep forgetting them. Just use autocomplete with the package and you can stop dealing with missed chars in your content types or forgetting what content types you can use.
This is a subset of all content types, only some of the more common ones.
Complete list here: https://www.iana.org/assignments/media-types/media-types.xhtml
import module:
go get -u github.com/hunter32292/go-mtype
Include in application like so:
package main
import (
"io"
"log"
"net/http"
"github.com/hunter32292/go-mtype"
)
func main() {
http.HandleFunc("/health", Health)
log.Fatal(http.ListenAndServe("localhost:8080", nil))
}
func Health(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", mtype.ApplicationJson)
io.WriteString(w, `{"alive":"true"}`)
}