diff --git a/backend/main.go b/backend/main.go index 8f707dd..360c42d 100644 --- a/backend/main.go +++ b/backend/main.go @@ -3,6 +3,7 @@ package main import ( "database/sql" "fmt" + "io" "log" "net/http" "os" @@ -1603,6 +1604,50 @@ func connect() { } }) + router.GET("/api/pops/statusOP/:data/check-status-pops", func(c *gin.Context) { + data := c.Param("data") + url := "https://gateway.davaocity.gov.ph/api/pops/statusOP.ashx?oprefid=" + data + + resp, err := http.Get(url) + if err != nil { + c.AbortWithError(http.StatusBadRequest, err) + c.String(http.StatusBadRequest, err.Error()) + return + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + c.AbortWithError(http.StatusInternalServerError, err) + c.String(http.StatusInternalServerError, err.Error()) + return + } + + c.Data(resp.StatusCode, "application/json", body) + }) + + router.GET("/api/pops/voidOP/:data/void-pops", func(c *gin.Context) { + data := c.Param("data") + url := "https://gateway.davaocity.gov.ph/api/pops/voidOP.ashx?oprefid=" + data + + resp, err := http.Get(url) + if err != nil { + c.AbortWithError(http.StatusBadRequest, err) + c.String(http.StatusBadRequest, err.Error()) + return + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + c.AbortWithError(http.StatusInternalServerError, err) + c.String(http.StatusInternalServerError, err.Error()) + return + } + + c.Data(resp.StatusCode, "application/json", body) + }) + router.POST("/api/post-registration", middleware.TokenChecker(), func(c *gin.Context) { type RegistrationData struct { Data int `json:"data"`