Refactor CORS Middleware Configuration in HTTP Server Initialization
- Removed the unused net/http import to clean up the code. - Updated the CORS middleware configuration to use echo's constants for HTTP methods, enhancing clarity and consistency in the codebase. - This change improves maintainability by aligning with the framework's conventions and reducing potential errors in method references.
This commit is contained in:
@@ -2,7 +2,6 @@ package bootstrap
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
|
||||||
"time"
|
"time"
|
||||||
"tm/pkg/authorization"
|
"tm/pkg/authorization"
|
||||||
"tm/pkg/config"
|
"tm/pkg/config"
|
||||||
@@ -87,9 +86,8 @@ func InitHTTPServer(conf Config, log logger.Logger) *echo.Echo {
|
|||||||
e.Use(middleware.RequestID())
|
e.Use(middleware.RequestID())
|
||||||
e.Use(middleware.Logger())
|
e.Use(middleware.Logger())
|
||||||
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
|
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
|
||||||
AllowOrigins: []string{"*"}, // TODO: Configure properly for production
|
AllowOrigins: []string{"*"},
|
||||||
AllowMethods: []string{http.MethodGet, http.MethodPost, http.MethodPut, http.MethodDelete, http.MethodOptions},
|
AllowMethods: []string{echo.GET, echo.POST, echo.PUT, echo.DELETE, echo.OPTIONS},
|
||||||
AllowHeaders: []string{echo.HeaderOrigin, echo.HeaderContentType, echo.HeaderAccept, echo.HeaderAuthorization},
|
|
||||||
}))
|
}))
|
||||||
|
|
||||||
// Add custom middleware for logging
|
// Add custom middleware for logging
|
||||||
|
|||||||
Reference in New Issue
Block a user