12345678910111213141516171819202122232425262728293031323334 |
- package got
- import (
- G "github.com/dave/jennifer/jen"
- )
- var (
- parser = "github.com/eugeniucarvalho/metric-query-parser/parser"
- GenMetricsStmts = &Middleware{
- Id: "metrics",
- Type: "method",
- Fn: func(ctx *MiddlewareContext) error {
- ctx.Statement.Block(G.Id(`
- var (
- metrics = `).Qual(parser, "MetricsMap").Values().Id(`
- errResolve error
- )
-
- if err = api.ReadJson(ctx, &metrics); err != nil {
- return
- }
-
- if resp, errResolve = `).Qual(parser, "NewMetricQueryParser").Call().Id(`.Resolve(metrics); errResolve != nil {
- err = errs.Internal().Details(&errs.Detail{
- Reason: "metricHandlerError",
- Message: errResolve.Error(),
- })
- }
- return`)).Line()
- return nil
- },
- }
- )
|