Skip to content

Commit

Permalink
add status endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
denyskon committed Jan 6, 2024
1 parent 4ea1eb3 commit 7830b60
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package main
import (
"fmt"
"net/http"
"runtime/debug"

mail_services "github.com/denyskon/postalion/email"
form_service "github.com/denyskon/postalion/form"
Expand Down Expand Up @@ -62,6 +63,17 @@ func main() {
router := pat.New()

router.Post("/form/{name}", formHandler)
router.Get("/status", func(wr http.ResponseWriter, req *http.Request) {
info, ok := debug.ReadBuildInfo()
if !ok {
log.Error("Failed to read build info")
wr.WriteHeader(http.StatusInternalServerError)
wr.Write([]byte("Failed to read build info"))
}

wr.WriteHeader(http.StatusOK)
wr.Write([]byte(fmt.Sprintf("POSTalion %s", info.Main.Version)))
})

http.Handle("/", router)

Expand Down

0 comments on commit 7830b60

Please sign in to comment.