Files
server/app/http/middleware/development.go
T
2026-01-16 15:49:34 +08:00

22 lines
517 B
Go

package middleware
import (
"github.com/goravel/framework/contracts/http"
"github.com/goravel/framework/facades"
)
func DevelopmentOnly() http.Middleware {
return func(ctx http.Context) {
env := facades.Config().Get("app.env", "production")
if env != "local" && env != "development" {
ctx.Response().Json(http.StatusForbidden, map[string]any{
"code": 403,
"message": "This feature is only available in development mode",
})
ctx.Request().Abort()
return
}
ctx.Request().Next()
}
}