fix: align inbox project routes
This commit is contained in:
22
backend/internal/httpx/router_integration_test.go
Normal file
22
backend/internal/httpx/router_integration_test.go
Normal 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{})),
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user