chore: use tx for stores

This commit is contained in:
boojack
2022-08-07 10:17:12 +08:00
parent 8c28721839
commit d8e10ba399
9 changed files with 279 additions and 197 deletions

View File

@ -16,6 +16,7 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {
})
g.GET("/r/:resourceId/:filename", func(c echo.Context) error {
ctx := c.Request().Context()
resourceID, err := strconv.Atoi(c.Param("resourceId"))
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("resourceId"))).SetInternal(err)
@ -26,7 +27,7 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {
ID: &resourceID,
Filename: &filename,
}
resource, err := s.Store.FindResource(resourceFind)
resource, err := s.Store.FindResource(ctx, resourceFind)
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch resource ID: %v", resourceID)).SetInternal(err)
}