Issue 9 chat api (#25)
This commit is contained in:
@@ -34,7 +34,7 @@ func main() {
|
||||
|
||||
// ── Auth routes (rate limited) ──────────────
|
||||
auth := handlers.NewAuthHandler(cfg)
|
||||
authLimiter := middleware.NewRateLimiter(1, 5) // 1 req/s, burst of 5
|
||||
authLimiter := middleware.NewRateLimiter(1, 5)
|
||||
|
||||
api := r.Group("/api/v1")
|
||||
{
|
||||
@@ -52,27 +52,30 @@ func main() {
|
||||
protected.Use(middleware.Auth(cfg))
|
||||
{
|
||||
// Chats
|
||||
protected.GET("/chats", handleListChats)
|
||||
protected.POST("/chats", handleCreateChat)
|
||||
protected.GET("/chats/:id", handleGetChat)
|
||||
protected.PUT("/chats/:id", handleUpdateChat)
|
||||
protected.DELETE("/chats/:id", handleDeleteChat)
|
||||
chats := handlers.NewChatHandler()
|
||||
protected.GET("/chats", chats.ListChats)
|
||||
protected.POST("/chats", chats.CreateChat)
|
||||
protected.GET("/chats/:id", chats.GetChat)
|
||||
protected.PUT("/chats/:id", chats.UpdateChat)
|
||||
protected.DELETE("/chats/:id", chats.DeleteChat)
|
||||
|
||||
// Messages
|
||||
protected.GET("/chats/:id/messages", handleGetMessages)
|
||||
protected.POST("/chats/:id/messages", handleCreateMessage)
|
||||
msgs := handlers.NewMessageHandler()
|
||||
protected.GET("/chats/:id/messages", msgs.ListMessages)
|
||||
protected.POST("/chats/:id/messages", msgs.CreateMessage)
|
||||
protected.POST("/chats/:id/regenerate", msgs.Regenerate)
|
||||
|
||||
// Settings
|
||||
protected.GET("/settings", handleGetSettings)
|
||||
protected.PUT("/settings", handleUpdateSettings)
|
||||
// Settings — ticket #10
|
||||
protected.GET("/settings", stubHandler("settings"))
|
||||
protected.PUT("/settings", stubHandler("settings"))
|
||||
|
||||
// API Configs
|
||||
protected.GET("/api-configs", handleListAPIConfigs)
|
||||
protected.POST("/api-configs", handleCreateAPIConfig)
|
||||
protected.DELETE("/api-configs/:id", handleDeleteAPIConfig)
|
||||
// API Configs — ticket #10
|
||||
protected.GET("/api-configs", stubHandler("api-configs"))
|
||||
protected.POST("/api-configs", stubHandler("api-configs"))
|
||||
protected.DELETE("/api-configs/:id", stubHandler("api-configs"))
|
||||
|
||||
// Models
|
||||
protected.GET("/models", handleListModels)
|
||||
// Models — ticket #10
|
||||
protected.GET("/models", stubHandler("models"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,21 +85,8 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
// Placeholder handlers — ticket #9
|
||||
func handleListChats(c *gin.Context) { c.JSON(501, gin.H{"error": "not implemented"}) }
|
||||
func handleCreateChat(c *gin.Context) { c.JSON(501, gin.H{"error": "not implemented"}) }
|
||||
func handleGetChat(c *gin.Context) { c.JSON(501, gin.H{"error": "not implemented"}) }
|
||||
func handleUpdateChat(c *gin.Context) { c.JSON(501, gin.H{"error": "not implemented"}) }
|
||||
func handleDeleteChat(c *gin.Context) { c.JSON(501, gin.H{"error": "not implemented"}) }
|
||||
func handleGetMessages(c *gin.Context) { c.JSON(501, gin.H{"error": "not implemented"}) }
|
||||
func handleCreateMessage(c *gin.Context) { c.JSON(501, gin.H{"error": "not implemented"}) }
|
||||
func handleGetSettings(c *gin.Context) { c.JSON(501, gin.H{"error": "not implemented"}) }
|
||||
func handleUpdateSettings(c *gin.Context) { c.JSON(501, gin.H{"error": "not implemented"}) }
|
||||
func handleListAPIConfigs(c *gin.Context) { c.JSON(501, gin.H{"error": "not implemented"}) }
|
||||
func handleCreateAPIConfig(c *gin.Context) {
|
||||
c.JSON(501, gin.H{"error": "not implemented"})
|
||||
func stubHandler(feature string) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
c.JSON(501, gin.H{"error": feature + " not implemented"})
|
||||
}
|
||||
}
|
||||
func handleDeleteAPIConfig(c *gin.Context) {
|
||||
c.JSON(501, gin.H{"error": "not implemented"})
|
||||
}
|
||||
func handleListModels(c *gin.Context) { c.JSON(501, gin.H{"error": "not implemented"}) }
|
||||
|
||||
Reference in New Issue
Block a user