Skip to content

Commit

Permalink
test trigger link
Browse files Browse the repository at this point in the history
  • Loading branch information
mstgnz committed Jul 7, 2024
1 parent ac4b712 commit 725c386
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ func main() {
http.ServeFile(w, r, "./views/swagger.html")
})

// test route
r.Get("/trigger", Catch(webHomeHandler.TriggerHandler))

// web without auth
r.Group(func(r chi.Router) {
r.Use(isAuthMiddleware)
Expand Down
5 changes: 5 additions & 0 deletions handler/web/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package web
import (
"net/http"

"github.com/mstgnz/cronjob/config"
"github.com/mstgnz/cronjob/services"
)

Expand All @@ -11,3 +12,7 @@ type HomeHandler struct{}
func (h *HomeHandler) HomeHandler(w http.ResponseWriter, r *http.Request) error {
return services.Render(w, r, "home", map[string]any{})
}

func (h *HomeHandler) TriggerHandler(w http.ResponseWriter, r *http.Request) error {
return config.WriteJSON(w, http.StatusOK, config.Response{Status: true, Message: "triggered", Data: nil})
}

0 comments on commit 725c386

Please sign in to comment.