mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +01:00
add human-friendly middleware names on route debugging (see HISTORY.md#Next)
Former-commit-id: f7291c4a077c4d1573344c93ba8a153fede18795
This commit is contained in:
parent
b657c5e6af
commit
c366c34644
|
@ -132,7 +132,7 @@ func (h *routerHandler) Build(provider RoutesProvider) error {
|
||||||
|
|
||||||
for _, r := range registeredRoutes {
|
for _, r := range registeredRoutes {
|
||||||
if h.config != nil && h.config.GetForceLowercaseRouting() {
|
if h.config != nil && h.config.GetForceLowercaseRouting() {
|
||||||
// only in that state, keep everyting else as end-developer registered.
|
// only in that state, keep everything else as end-developer registered.
|
||||||
r.Path = strings.ToLower(r.Path)
|
r.Path = strings.ToLower(r.Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ func (h *routerHandler) Build(provider RoutesProvider) error {
|
||||||
tr = tr[0 : len(tr)-1]
|
tr = tr[0 : len(tr)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
golog.Debugf("API: [%d] %s", len(registeredRoutes), tr)
|
golog.Debugf("API: %d registered %s", len(registeredRoutes), tr)
|
||||||
|
|
||||||
// group routes by method and print them without the [DBUG] and time info,
|
// group routes by method and print them without the [DBUG] and time info,
|
||||||
// the route logs are colorful.
|
// the route logs are colorful.
|
||||||
|
|
|
@ -343,6 +343,7 @@ func (r *Route) ResolvePath(args ...string) string {
|
||||||
|
|
||||||
var ignoreHandlersTraces = [...]string{
|
var ignoreHandlersTraces = [...]string{
|
||||||
"iris/macro/handler.MakeHandler",
|
"iris/macro/handler.MakeHandler",
|
||||||
|
"iris/hero.makeHandler.func2",
|
||||||
"iris/core/router.(*APIBuilder).Favicon",
|
"iris/core/router.(*APIBuilder).Favicon",
|
||||||
"iris/core/router.StripPrefix",
|
"iris/core/router.StripPrefix",
|
||||||
}
|
}
|
||||||
|
|
31
iris.go
31
iris.go
|
@ -768,6 +768,24 @@ func (app *Application) Build() error {
|
||||||
app.Router.WrapRouter(app.I18n.Wrapper())
|
app.Router.WrapRouter(app.I18n.Wrapper())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if n := app.view.Len(); n > 0 {
|
||||||
|
tr := "engines"
|
||||||
|
if n == 1 {
|
||||||
|
tr = tr[0 : len(tr)-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
app.logger.Debugf("Application: %d registered view %s", n, tr)
|
||||||
|
// view engine
|
||||||
|
// here is where we declare the closed-relative framework functions.
|
||||||
|
// Each engine has their defaults, i.e yield,render,render_r,partial, params...
|
||||||
|
rv := router.NewRoutePathReverser(app.APIBuilder)
|
||||||
|
app.view.AddFunc("urlpath", rv.Path)
|
||||||
|
// app.view.AddFunc("url", rv.URL)
|
||||||
|
if err := app.view.Load(); err != nil {
|
||||||
|
rp.Group("View Builder").Err(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !app.Router.Downgraded() {
|
if !app.Router.Downgraded() {
|
||||||
// router
|
// router
|
||||||
if err := app.tryInjectLiveReload(); err != nil {
|
if err := app.tryInjectLiveReload(); err != nil {
|
||||||
|
@ -790,19 +808,6 @@ func (app *Application) Build() error {
|
||||||
// re-build of the router from outside can be done with
|
// re-build of the router from outside can be done with
|
||||||
// app.RefreshRouter()
|
// app.RefreshRouter()
|
||||||
}
|
}
|
||||||
|
|
||||||
if app.view.Len() > 0 {
|
|
||||||
app.logger.Debugf("Application: %d registered view engine(s)", app.view.Len())
|
|
||||||
// view engine
|
|
||||||
// here is where we declare the closed-relative framework functions.
|
|
||||||
// Each engine has their defaults, i.e yield,render,render_r,partial, params...
|
|
||||||
rv := router.NewRoutePathReverser(app.APIBuilder)
|
|
||||||
app.view.AddFunc("urlpath", rv.Path)
|
|
||||||
// app.view.AddFunc("url", rv.URL)
|
|
||||||
if err := app.view.Load(); err != nil {
|
|
||||||
rp.Group("View Builder").Err(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return errgroup.Check(rp)
|
return errgroup.Check(rp)
|
||||||
|
|
|
@ -12,6 +12,10 @@ import (
|
||||||
"github.com/kataras/iris/v12/context"
|
"github.com/kataras/iris/v12/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
context.SetHandlerName("iris/middleware/basicauth.*", "Basic Authentication")
|
||||||
|
}
|
||||||
|
|
||||||
type (
|
type (
|
||||||
encodedUser struct {
|
encodedUser struct {
|
||||||
HeaderValue string
|
HeaderValue string
|
||||||
|
|
|
@ -10,6 +10,10 @@ import (
|
||||||
"github.com/kataras/iris/v12/context"
|
"github.com/kataras/iris/v12/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
context.SetHandlerName("iris/middleware/hcaptcha.*", "hCaptcha")
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// ResponseContextKey is the default request's context key that response of a hcaptcha request is kept.
|
// ResponseContextKey is the default request's context key that response of a hcaptcha request is kept.
|
||||||
ResponseContextKey string = "iris.hcaptcha"
|
ResponseContextKey string = "iris.hcaptcha"
|
||||||
|
|
|
@ -11,6 +11,10 @@ import (
|
||||||
"github.com/kataras/iris/v12/core/handlerconv"
|
"github.com/kataras/iris/v12/core/handlerconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
context.SetHandlerName("iris/middleware/pprof.*", "Profiling")
|
||||||
|
}
|
||||||
|
|
||||||
// New returns a new pprof (profile, cmdline, symbol, goroutine, heap, threadcreate, debug/block) Middleware.
|
// New returns a new pprof (profile, cmdline, symbol, goroutine, heap, threadcreate, debug/block) Middleware.
|
||||||
// Note: Route MUST have the last named parameter wildcard named '{action:path}'
|
// Note: Route MUST have the last named parameter wildcard named '{action:path}'
|
||||||
func New() context.Handler {
|
func New() context.Handler {
|
||||||
|
|
|
@ -11,6 +11,10 @@ import (
|
||||||
"github.com/kataras/iris/v12/core/netutil"
|
"github.com/kataras/iris/v12/core/netutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
context.SetHandlerName("iris/middleware/recaptcha.*", "reCAPTCHA")
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// responseFormValue = "g-recaptcha-response"
|
// responseFormValue = "g-recaptcha-response"
|
||||||
apiURL = "https://www.google.com/recaptcha/api/siteverify"
|
apiURL = "https://www.google.com/recaptcha/api/siteverify"
|
||||||
|
|
|
@ -9,6 +9,10 @@ import (
|
||||||
"github.com/kataras/iris/v12/context"
|
"github.com/kataras/iris/v12/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
context.SetHandlerName("iris/middleware/recover.*", "Panic Recover")
|
||||||
|
}
|
||||||
|
|
||||||
func getRequestLogs(ctx context.Context) string {
|
func getRequestLogs(ctx context.Context) string {
|
||||||
var status, ip, method, path string
|
var status, ip, method, path string
|
||||||
status = strconv.Itoa(ctx.GetStatusCode())
|
status = strconv.Itoa(ctx.GetStatusCode())
|
||||||
|
|
Loading…
Reference in New Issue
Block a user