mirror of
https://github.com/kataras/iris.git
synced 2025-12-21 20:07:04 +00:00
add the ability to add custom parameter types to the interpreter and mapped macros with any number of macro functions - example added - although it's working it is not ready yet - I have to do some cleanup, doc comments and a TODO
Former-commit-id: 8ac751b649a3b8e59948fd4c89ad53d25f49d0d5
This commit is contained in:
@@ -5,19 +5,31 @@ import (
|
||||
"reflect"
|
||||
"runtime"
|
||||
|
||||
"github.com/kataras/iris/context"
|
||||
"github.com/kataras/iris/core/memstore"
|
||||
"github.com/kataras/iris/hero/di"
|
||||
|
||||
"github.com/kataras/golog"
|
||||
"github.com/kataras/iris/context"
|
||||
)
|
||||
|
||||
var contextTyp = reflect.TypeOf((*context.Context)(nil)).Elem()
|
||||
var (
|
||||
contextTyp = reflect.TypeOf((*context.Context)(nil)).Elem()
|
||||
memstoreTyp = reflect.TypeOf(memstore.Store{})
|
||||
)
|
||||
|
||||
// IsContext returns true if the "inTyp" is a type of Context.
|
||||
func IsContext(inTyp reflect.Type) bool {
|
||||
return inTyp.Implements(contextTyp)
|
||||
}
|
||||
|
||||
// IsExpectingStore returns true if the "inTyp" is a type of memstore.Store.
|
||||
func IsExpectingStore(inTyp reflect.Type) bool {
|
||||
print("di/handler.go: " + inTyp.String() + " vs " + memstoreTyp.String() + " : ")
|
||||
println(inTyp == memstoreTyp)
|
||||
|
||||
return inTyp == memstoreTyp
|
||||
}
|
||||
|
||||
// checks if "handler" is context.Handler: func(context.Context).
|
||||
func isContextHandler(handler interface{}) (context.Handler, bool) {
|
||||
h, is := handler.(context.Handler)
|
||||
@@ -70,7 +82,7 @@ func makeHandler(handler interface{}, values ...reflect.Value) (context.Handler,
|
||||
// is invalid when input len and values are not match
|
||||
// or their types are not match, we will take look at the
|
||||
// second statement, here we will re-try it
|
||||
// using binders for path parameters: string, int, int64, bool.
|
||||
// using binders for path parameters: string, int, int64, uint8, uint64, bool and so on.
|
||||
// We don't have access to the path, so neither to the macros here,
|
||||
// but in mvc. So we have to do it here.
|
||||
if valid = funcInjector.Retry(new(params).resolve); !valid {
|
||||
|
||||
Reference in New Issue
Block a user