Skip to content

Commit

Permalink
Migrate action routes to /api
Browse files Browse the repository at this point in the history
  • Loading branch information
diamondburned committed Jun 19, 2024
1 parent 0a110c4 commit 25b14fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ func New(deps Dependencies) *Server {
r.Get("/", s.handleIndex)
r.Get("/dosages.json", s.getDosagesJSON)

r.Post("/notify/test", s.handleGotifyTest)
r.Post("/dosage/record", s.handleRecordDosage)
r.Post("/dosage/delete", s.handleDeleteDosage)
r.Route("/api", func(r chi.Router) {
r.Post("/notify/test", s.handleGotifyTest)
r.Post("/dosage/record", s.handleRecordDosage)
r.Post("/dosage/delete", s.handleDeleteDosage)
})

r.Route("/static", func(r chi.Router) {
r.Use(middleware.Compress(5))
Expand Down
4 changes: 2 additions & 2 deletions web/pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ <h1>hrtclicker</h1>

<section id="dosage-control">
<form method="post">
<button type="submit" id="record-dose" formaction="/dosage/record">
<button type="submit" id="record-dose" formaction="/api/dosage/record">
<span>I took my dose</span>
<span>😺✨</span>
</button>
<button
type="submit"
id="delete-dose"
formaction="/dosage/delete"
formaction="/api/dosage/delete"
data-destructive
data-confirmation="Are you sure you want to delete your last dose?"
>
Expand Down

0 comments on commit 25b14fe

Please sign in to comment.