Ejemplo n.º 1
0
// Just a catch-all for POST requests right now. Only allow default charset (utf8).
func contentTypeMW(c *gin.Context) {
	if c.Request.Method == "POST" && c.ContentType() != "application/json" {
		c.AbortWithError(415, fmt.Errorf("Media type not supported: "+c.ContentType()))
	} else {
		c.Next()
	}
}