mirror of
https://github.com/kataras/iris.git
synced 2026-01-18 01:15:59 +00:00
Add a better example for the recaptcha middleware as requested at: https://github.com/kataras/iris/issues/799
Former-commit-id: 85c3286a9d6be5cf47631e7608f70f3790934e64
This commit is contained in:
@@ -17,7 +17,6 @@ import (
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -1056,7 +1055,7 @@ func (ctx *context) Proceed(h Handler) bool {
|
||||
|
||||
// HandlerName returns the current handler's name, helpful for debugging.
|
||||
func (ctx *context) HandlerName() string {
|
||||
return runtime.FuncForPC(reflect.ValueOf(ctx.handlers[ctx.currentHandlerIndex]).Pointer()).Name()
|
||||
return HandlerName(ctx.handlers[ctx.currentHandlerIndex])
|
||||
}
|
||||
|
||||
// Do sets the handler index to zero, executes the first handler
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package context
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// A Handler responds to an HTTP request.
|
||||
// It writes reply headers and data to the Context.ResponseWriter() and then return.
|
||||
// Returning signals that the request is finished;
|
||||
@@ -20,3 +25,12 @@ type Handler func(Context)
|
||||
//
|
||||
// See `Handler` for more.
|
||||
type Handlers []Handler
|
||||
|
||||
// HandlerName returns the name, the handler function informations.
|
||||
// Same as `context.HandlerName`.
|
||||
func HandlerName(h Handler) string {
|
||||
pc := reflect.ValueOf(h).Pointer()
|
||||
// l, n := runtime.FuncForPC(pc).FileLine(pc)
|
||||
// return fmt.Sprintf("%s:%d", l, n)
|
||||
return runtime.FuncForPC(pc).Name()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user