diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..66ff498 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +# syntax=docker/dockerfile:1 + +FROM golang:1.23 + +WORKDIR /app + +COPY go.mod ./ + +RUN go mod download + +COPY . . + +RUN go build -o /Mensa-API + +EXPOSE 80 + +CMD [ "/Mensa-API" ] \ No newline at end of file diff --git a/scrape/state.go b/scrape/state.go index 443097b..626dbf7 100644 --- a/scrape/state.go +++ b/scrape/state.go @@ -17,7 +17,6 @@ func ScrapeState(h io.ReadCloser) []string { doc.Find("a.primary").Each(func(i int, s *goquery.Selection) { href, _ := s.Attr("href") - print(href) city := strings.Split(href, "/")[0] diff --git a/server/server.go b/server/server.go index e191582..b3dbd12 100644 --- a/server/server.go +++ b/server/server.go @@ -5,14 +5,16 @@ import ( ) func Run() { + gin.SetMode(gin.ReleaseMode) r := gin.Default() - r.GET("/ping", func(c *gin.Context) { + + r.GET("/", func(c *gin.Context) { c.JSON(200, gin.H{ - "message": "pong", + "message": "Mensen API", }) }) r.GET("/state/:state", state) r.GET("/city/:city", city) r.GET("/mensa/:city/:mensa", mensa) - r.Run() // listen and serve on + r.Run(":80") }