Skip to content

Commit 3ad2155

Browse files
author
Wilfried OLLIVIER
committed
More routes for latest path
1 parent 4f58a91 commit 3ad2155

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

application/application.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,16 @@ func New(cfg *conf.Conf) (*Application, error) {
135135
r.Route("/{branch}", func(r chi.Router) {
136136
r.Route("/{commit}", func(r chi.Router) {
137137
r.Post("/", a.PostTaskHandler)
138-
r.Get("/", a.TaskHandler)
138+
r.Get("/", a.TaskHandler(false))
139139
r.Get("/status", badge.StatusBadge(a.storage, false))
140140
r.Get("/badge/{badge}", a.TaskMyBadgeHandler)
141-
r.Get("/volumes/*", a.VolumesHandler(6))
141+
r.Get("/volumes/*", a.VolumesHandler(6, false))
142+
})
143+
r.Route("/latest", func(r chi.Router) {
144+
r.Get("/", a.TaskHandler(true))
145+
r.Get("/status", badge.StatusBadge(a.storage, true))
146+
r.Get("/volumes/*", a.VolumesHandler(6, true))
142147
})
143-
r.Get("/latest", nil)
144-
r.Get("/latest/status", badge.StatusBadge(a.storage, true))
145148
})
146149
})
147150
})

application/volume.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

1515
// VolumesHandler expose volumes of a task
16-
func (a *Application) VolumesHandler(basePathLen int) http.HandlerFunc {
16+
func (a *Application) VolumesHandler(basePathLen int, latest bool) http.HandlerFunc {
1717
return func(w http.ResponseWriter, r *http.Request) {
1818
l := a.logger.With(
1919
zap.String("url", r.URL.String()),
@@ -28,7 +28,7 @@ func (a *Application) VolumesHandler(basePathLen int) http.HandlerFunc {
2828
branch := chi.URLParam(r, "branch")
2929
commit := chi.URLParam(r, "commit")
3030

31-
t, err := a.storage.GetByCommit(service, project, branch, commit, false)
31+
t, err := a.storage.GetByCommit(service, project, branch, commit, latest)
3232
if err != nil {
3333
l.Error("Get task", zap.Error(err))
3434
w.WriteHeader(http.StatusNotFound)

0 commit comments

Comments
 (0)