Based on QuantumNous/new-api v1.0.0-rc.36 (shallow history squashed). - CNY quota display mode: RMB-denominated top-up and crediting across Epay/Waffo channels - New CheckinButton in both authenticated and public headers (Turnstile supported) - New /subscribe page with public plan snapshot, Alipay/balance payment, auto group upgrade/reset - New /docs 12-section beginner guide with anchor navigation - New home PromoBanner linking to /docs; i18n synced (en/zh/zh-TW/fr/ja/ru/vi) - README: document custom features, live demo https://ai.88531.cn
38 lines
1.3 KiB
Go
38 lines
1.3 KiB
Go
package router
|
|
|
|
import (
|
|
"github.com/QuantumNous/new-api/controller"
|
|
"github.com/QuantumNous/new-api/middleware"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// SetTaskRouter registers the generic task-plugin API surface.
|
|
//
|
|
// Gin requires every route sharing a path position to use the same wildcard
|
|
// name, so the first segment is uniformly ":key"; it carries the plugin key
|
|
// on submit routes and the task id on read routes.
|
|
func SetTaskRouter(router *gin.Engine) {
|
|
taskSubmitRouter := router.Group("/v1/tasks")
|
|
taskSubmitRouter.Use(middleware.RouteTag("relay"), middleware.TokenAuth())
|
|
{
|
|
taskSubmitRouter.POST("/:key", middleware.PrepareTaskPluginSubmit(), middleware.Distribute(), controller.RelayTask)
|
|
}
|
|
|
|
taskReadRouter := router.Group("/v1/tasks")
|
|
taskReadRouter.Use(middleware.RouteTag("relay"), middleware.TokenAuth())
|
|
{
|
|
taskReadRouter.GET("/:key", controller.GetTask)
|
|
taskReadRouter.GET("/:key/artifacts", controller.GetTaskArtifacts)
|
|
}
|
|
|
|
taskContentRouter := router.Group("/v1/tasks")
|
|
taskContentRouter.Use(
|
|
middleware.RouteTag("relay"),
|
|
middleware.TokenOrTaskArtifactAccessAuth("key", "artifact_key"),
|
|
)
|
|
{
|
|
taskContentRouter.GET("/:key/artifacts/:artifact_key/content", controller.TaskArtifactContent)
|
|
taskContentRouter.HEAD("/:key/artifacts/:artifact_key/content", controller.TaskArtifactContent)
|
|
}
|
|
}
|