Skip to content

Commit

Permalink
Merge pull request #23 from teknologi-umum/feat/backend/ping-endpoint
Browse files Browse the repository at this point in the history
feat(backend): ping endpoint
  • Loading branch information
aldy505 authored Sep 1, 2023
2 parents 3249527 + 08e4d5b commit d21e740
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@ FROM debian:bookworm-slim AS runtime

WORKDIR /app

RUN apt-get update && \
apt-get install -y curl && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

ARG PORT=8080

RUN mkdir -p /app/csv

COPY --from=build /app/ .

HEALTHCHECK --interval=60s --timeout=40s \
CMD curl -f http://localhost:8080/ping || exit 1

EXPOSE ${PORT}

CMD ["/app/conf-backend", "server"]
6 changes: 5 additions & 1 deletion backend/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@ func NewServer(config *ServerConfig) *echo.Echo {
// NOTE: Only need to handle CORS, everything else is being handled by the API gateway
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
AllowOrigins: []string{"https://conf.teknologiumum.com"},
AllowMethods: []string{"POST"},
AllowMethods: []string{http.MethodPost},
AllowHeaders: []string{echo.HeaderOrigin, echo.HeaderContentType, echo.HeaderAccept},
AllowCredentials: false,
MaxAge: 3600, // 1 day
}))

e.Use(middleware.RequestID())

e.GET("/ping", func(c echo.Context) error {
return c.NoContent(http.StatusOK)
})

e.POST("/users", func(c echo.Context) error {
requestId := c.Request().Header.Get(echo.HeaderXRequestID)
sentryHub := sentryecho.GetHubFromContext(c)
Expand Down

0 comments on commit d21e740

Please sign in to comment.