fix: align inbox project routes

This commit is contained in:
2026-07-20 22:35:45 +08:00
parent c1a144cb44
commit 54958382f1
5 changed files with 93 additions and 11 deletions

View File

@@ -0,0 +1,22 @@
package httpx_test
import (
"testing"
"github.com/stretchr/testify/require"
"senlinai-agent/backend/internal/config"
"senlinai-agent/backend/internal/httpx"
"senlinai-agent/backend/internal/logic/inbox"
"senlinai-agent/backend/internal/logic/projects"
)
func TestProjectAndInboxRoutesRegisterTogether(t *testing.T) {
require.NotPanics(t, func() {
httpx.NewProtectedRouter(
config.Config{Env: "test"},
func(token string) (uint, error) { return 1, nil },
projects.NewHandler(projects.NewService()),
inbox.NewHandler(inbox.NewService(inbox.StaticAnalyzer{})),
)
})
}

View File

@@ -17,7 +17,7 @@ func NewHandler(service *Service) *Handler {
}
func (h *Handler) Register(router gin.IRouter) {
router.POST("/projects/:projectID/inbox", h.capture)
router.POST("/projects/:id/inbox", h.capture)
router.POST("/inbox/:id/analyze", h.analyze)
router.POST("/inbox/:id/confirm", h.confirm)
}
@@ -28,7 +28,7 @@ func (h *Handler) capture(c *gin.Context) {
c.JSON(http.StatusUnauthorized, gin.H{"error": "missing current user"})
return
}
projectID, err := strconv.ParseUint(c.Param("projectID"), 10, 64)
projectID, err := strconv.ParseUint(c.Param("id"), 10, 64)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid project id"})
return