mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-22 17:31:03 +01:00
refactor: standardize response types across controllers
- Updated multiple controller methods to return VoidResponse instead of generic Response[any]. - Consolidated error handling to utilize GetErrorVoidResponse for consistent error responses. - Enhanced parameter handling in export and file management functions for improved clarity and maintainability. - Refactored health check and login/logout methods to align with new response structure. - Improved overall consistency in response formatting across various endpoints.
This commit is contained in:
@@ -4,10 +4,10 @@ import (
|
||||
"fmt"
|
||||
"github.com/crawlab-team/crawlab/core/interfaces"
|
||||
"github.com/crawlab-team/crawlab/core/utils"
|
||||
"github.com/loopfz/gadgeto/tonic"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/loopfz/gadgeto/tonic"
|
||||
"github.com/wI2L/fizz"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// FizzWrapper wraps an existing Gin Engine to add OpenAPI functionality
|
||||
@@ -17,9 +17,9 @@ type FizzWrapper struct {
|
||||
logger interfaces.Logger
|
||||
}
|
||||
|
||||
// NewFizzWrapper creates a new wrapper around an existing Gin Engine
|
||||
// newFizzWrapper creates a new wrapper around an existing Gin Engine
|
||||
// This approach ensures we don't break existing functionality
|
||||
func NewFizzWrapper(engine *gin.Engine) *FizzWrapper {
|
||||
func newFizzWrapper(engine *gin.Engine) *FizzWrapper {
|
||||
// Create a new Fizz instance using the existing Gin engine
|
||||
f := fizz.NewFromEngine(engine)
|
||||
return &FizzWrapper{
|
||||
@@ -116,3 +116,13 @@ func (w *FizzWrapper) buildOperationOptions(id, summary, description string, res
|
||||
|
||||
return opts
|
||||
}
|
||||
|
||||
var wrapper *FizzWrapper
|
||||
var wrapperOnce sync.Once
|
||||
|
||||
func GetFizzWrapper(app *gin.Engine) *FizzWrapper {
|
||||
wrapperOnce.Do(func() {
|
||||
wrapper = newFizzWrapper(app)
|
||||
})
|
||||
return wrapper
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user