mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-21 16:49:03 +01:00
- Introduced `NewTestRoute` function to simplify route creation in benchmark tests. - Replaced direct route validation and starting with error handling using `require.NoError`. - Updated server retrieval to use `common.ProxyHTTPAddr` for consistency. - Improved logging for HTTP route addition errors in `AddRoute` method. * fix(tcp): wrap proxy proto listener before acl * refactor(entrypoint): propagate errors from route registration and stream serving * fix(docs): correct swagger and package README
34 lines
907 B
Go
34 lines
907 B
Go
package routeApi
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
entrypoint "github.com/yusing/godoxy/internal/entrypoint/types"
|
|
"github.com/yusing/godoxy/internal/route"
|
|
|
|
apitypes "github.com/yusing/goutils/apitypes"
|
|
)
|
|
|
|
type RoutesByProvider map[string][]route.Route
|
|
|
|
// @x-id "byProvider"
|
|
// @BasePath /api/v1
|
|
// @Summary List routes by provider
|
|
// @Description List routes by provider
|
|
// @Tags route
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Success 200 {object} RoutesByProvider
|
|
// @Failure 403 {object} apitypes.ErrorResponse
|
|
// @Failure 500 {object} apitypes.ErrorResponse
|
|
// @Router /route/by_provider [get]
|
|
func ByProvider(c *gin.Context) {
|
|
ep := entrypoint.FromCtx(c.Request.Context())
|
|
if ep == nil { // impossible, but just in case
|
|
c.JSON(http.StatusInternalServerError, apitypes.Error("entrypoint not initialized"))
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, ep.RoutesByProvider())
|
|
}
|