package main

import (
	"io/ioutil"
	"strconv"

	"github.com/gin-gonic/gin"
	"github.com/mdeheij/gitlegram/gitlab"
	log "github.com/mdeheij/logwrap"
)

func main() {
	c := NewConfig()
	//gin.SetMode(gin.ReleaseMode)
	r := gin.Default()

	r.POST("/", func(c *gin.Context) {
		body, ioerr := ioutil.ReadAll(c.Request.Body)
		if ioerr != nil {
			c.String(400, "Could not read request body")
			log.Critical(ioerr)
			return
		}

		//TODO: Request can be ambiguous
		request, err := gitlab.Parse(string(body))
		if err != nil {
			c.String(400, "Could not parse request body")
			log.Critical(err)
			return
		}
		c.JSON(200, getMessage(request))

	})
	address := c.Address + ":" + strconv.FormatInt(c.Port, 10)
	r.Run(address)
}

package main

import (
	"io/ioutil"
	"strconv"

	"github.com/gin-gonic/gin"
	"github.com/mdeheij/gitlegram/gitlab"
	log "github.com/mdeheij/logwrap"
)

func main() {
	c := NewConfig()
	//gin.SetMode(gin.ReleaseMode)
	r := gin.Default()

	r.POST("/", func(c *gin.Context) {
		body, ioerr := ioutil.ReadAll(c.Request.Body)
		if ioerr != nil {
			c.String(500, "Could not read request body")
			log.Critical(ioerr)
			return
		}

		//TODO: Request can be ambiguous
		request, err := gitlab.Parse(string(body))
		if err != nil {
			c.String(500, "Could not parse request body")
			log.Critical(err)
			return
		}
		c.JSON(200, getMessage(request))

	})
	address := c.Address + ":" + strconv.FormatInt(c.Port, 10)
	r.Run(address)
}

--- 
+++ 
@@ -17,7 +17,7 @@
 	r.POST("/", func(c *gin.Context) {
 		body, ioerr := ioutil.ReadAll(c.Request.Body)
 		if ioerr != nil {
-			c.String(500, "Could not read request body")
+			c.String(400, "Could not read request body")
 			log.Critical(ioerr)
 			return
 		}
@@ -25,7 +25,7 @@
 		//TODO: Request can be ambiguous
 		request, err := gitlab.Parse(string(body))
 		if err != nil {
-			c.String(500, "Could not parse request body")
+			c.String(400, "Could not parse request body")
 			log.Critical(err)
 			return
 		}
Change 500 Internal Server Error to 400 Bad Request
