|
@@ -285,11 +285,13 @@ func GenIndexApi(p *Project) error {
|
|
Index.Id(`
|
|
Index.Id(`
|
|
import(
|
|
import(
|
|
"reflect"
|
|
"reflect"
|
|
- "runtime"
|
|
|
|
|
|
+ "runtime"
|
|
|
|
+ "strings"
|
|
)
|
|
)
|
|
var (
|
|
var (
|
|
filtersApiReference = map[string]*`).Qual(CODE_GEN_V2_COMMON, "ApiFilter").Id(`{}
|
|
filtersApiReference = map[string]*`).Qual(CODE_GEN_V2_COMMON, "ApiFilter").Id(`{}
|
|
FormatSelection = map[string]string{}
|
|
FormatSelection = map[string]string{}
|
|
|
|
+ Debug = api.NewDebug()
|
|
)
|
|
)
|
|
func init(){
|
|
func init(){
|
|
var (
|
|
var (
|
|
@@ -310,21 +312,24 @@ func GenIndexApi(p *Project) error {
|
|
filtersApiReference[entity.Id] = entity
|
|
filtersApiReference[entity.Id] = entity
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
func executeAction(ctx context.Context, actions ...func(context.Context) (interface{}, *`).Qual(API_ERROR, "Error").Id(`)) (resp interface{},err *errs.Error){
|
|
func executeAction(ctx context.Context, actions ...func(context.Context) (interface{}, *`).Qual(API_ERROR, "Error").Id(`)) (resp interface{},err *errs.Error){
|
|
var (
|
|
var (
|
|
stopPropagation bool
|
|
stopPropagation bool
|
|
- debug = ctx.Values().Get("#debug");
|
|
|
|
parts []string
|
|
parts []string
|
|
)
|
|
)
|
|
|
|
+ debug, debugActive := ctx.Values().Get("#debug").(*api.DebugTaks);
|
|
|
|
+
|
|
for _, action := range actions {
|
|
for _, action := range actions {
|
|
- parts = strings.Split(runtime.FuncForPC(reflect.ValueOf(action).Pointer()).Name(), ".")
|
|
|
|
- event := debug.Event("execute.action", parts[len(parts)-1])
|
|
|
|
resp, err = action(ctx)
|
|
resp, err = action(ctx)
|
|
- event.Data = iris.M{
|
|
|
|
- "resp": resp,
|
|
|
|
- "err": err,
|
|
|
|
|
|
+
|
|
|
|
+ if debugActive {
|
|
|
|
+ parts = strings.Split(runtime.FuncForPC(reflect.ValueOf(action).Pointer()).Name(), ".")
|
|
|
|
+ event := debug.Event("execute.action", parts[len(parts)-1])
|
|
|
|
+ event.Data = resp
|
|
|
|
+ event.Error = err
|
|
}
|
|
}
|
|
|
|
|
|
stopPropagation,_ = ctx.Values().GetBool("stop.propagation")
|
|
stopPropagation,_ = ctx.Values().GetBool("stop.propagation")
|
|
@@ -346,6 +351,7 @@ func GenIndexApi(p *Project) error {
|
|
args := []G.Code{
|
|
args := []G.Code{
|
|
G.Lit(method.HttpMethod),
|
|
G.Lit(method.HttpMethod),
|
|
G.Lit(p.GetPath(method)),
|
|
G.Lit(p.GetPath(method)),
|
|
|
|
+ G.Lit("Debug.Handler()"),
|
|
}
|
|
}
|
|
|
|
|
|
middlewares = []string{}
|
|
middlewares = []string{}
|
|
@@ -418,6 +424,21 @@ func GenIndexApi(p *Project) error {
|
|
// G.Id(fmt.Sprintf(`FilterHandle("../api/%s/filters")`, p.Package)),
|
|
// G.Id(fmt.Sprintf(`FilterHandle("../api/%s/filters")`, p.Package)),
|
|
// ))
|
|
// ))
|
|
|
|
|
|
|
|
+ statments = append(statments, G.Line().Comment("Debug eventstream").Line().Id("app").Dot("Get").Call(
|
|
|
|
+ G.Lit("/debug"),
|
|
|
|
+ G.Id(`apply("debug", Debug.EventStream())`),
|
|
|
|
+ // G.Func().Params(G.Id("ctx").Qual(IRIS_CTX, "Context")).Block(
|
|
|
|
+
|
|
|
|
+ // G.Id(`
|
|
|
|
+ // if err = asyncTaskManagerService.Hub.UpgradeConnection(
|
|
|
|
+ // ctx,
|
|
|
|
+ // fmt.Sprintf("async.task.%s", asyncTaskId),
|
|
|
|
+ // ); err != nil {
|
|
|
|
+ // ctx.
|
|
|
|
+ // }
|
|
|
|
+ // `),
|
|
|
|
+ // ),
|
|
|
|
+ ))
|
|
// Cria a funcao que trata os metodos options
|
|
// Cria a funcao que trata os metodos options
|
|
statments = append(statments, G.Line().Comment("Options request").Line().Id("app").Dot("Options").Call(
|
|
statments = append(statments, G.Line().Comment("Options request").Line().Id("app").Dot("Options").Call(
|
|
G.Lit("/{url:path}"),
|
|
G.Lit("/{url:path}"),
|