2021-03-11 13:28:00 -06:00
|
|
|
{{>partial_header}}
|
|
|
|
package {{packageName}}
|
|
|
|
|
|
|
|
{{#operations}}
|
|
|
|
import (
|
|
|
|
"github.com/go-macaron/binding"
|
2021-04-09 04:55:41 -05:00
|
|
|
|
2021-03-11 13:28:00 -06:00
|
|
|
"github.com/grafana/grafana/pkg/api/routing"
|
|
|
|
"github.com/grafana/grafana/pkg/api/response"
|
|
|
|
"github.com/grafana/grafana/pkg/models"
|
2021-04-20 12:12:32 -05:00
|
|
|
apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
|
2021-04-06 09:22:05 -05:00
|
|
|
"github.com/grafana/grafana/pkg/middleware"
|
2021-03-11 13:28:00 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
type {{classname}}Service interface { {{#operation}}
|
|
|
|
{{nickname}}(*models.ReqContext{{#bodyParams}}, apimodels.{{dataType}}{{/bodyParams}}) response.Response{{/operation}}
|
|
|
|
}
|
|
|
|
|
2021-04-28 15:59:15 -05:00
|
|
|
func (api *API) Register{{classname}}Endpoints(srv {{classname}}Service, metrics *Metrics) {
|
2021-03-11 13:28:00 -06:00
|
|
|
api.RouteRegister.Group("", func(group routing.RouteRegister){ {{#operations}}{{#operation}}
|
2021-04-28 15:59:15 -05:00
|
|
|
group.{{httpMethod}}(
|
|
|
|
toMacaronPath("{{{path}}}"){{#bodyParams}},
|
|
|
|
binding.Bind(apimodels.{{dataType}}{}){{/bodyParams}},
|
|
|
|
Instrument(
|
|
|
|
http.Method{{httpMethod}},
|
|
|
|
"{{{path}}}",
|
|
|
|
srv.{{nickname}},
|
|
|
|
metrics,
|
|
|
|
),
|
|
|
|
){{/operation}}{{/operations}}
|
2021-04-06 09:22:05 -05:00
|
|
|
}, middleware.ReqSignedIn)
|
2021-03-11 13:28:00 -06:00
|
|
|
}{{#operation}}
|
2021-04-09 04:55:41 -05:00
|
|
|
{{/operation}}{{/operations}}
|