Expose route and app models to RunnerCall for extensions (alternative 2) (#880)

This commit is contained in:
Dario Domizioli
2018-03-22 20:07:39 +00:00
committed by Gerardo Viedma
parent 563a4576ef
commit 8df8ed6360
2 changed files with 15 additions and 0 deletions

View File

@@ -101,6 +101,7 @@ func FromRequest(appName, path string, req *http.Request) CallOpt {
Memory: route.Memory,
CPUs: route.CPUs,
Config: buildConfig(app, route),
Annotations: buildAnnotations(app, route),
Headers: req.Header,
CreatedAt: strfmt.DateTime(time.Now()),
URL: reqURL(req),
@@ -135,6 +136,17 @@ func buildConfig(app *models.App, route *models.Route) models.Config {
return conf
}
func buildAnnotations(app *models.App, route *models.Route) models.Annotations {
ann := make(models.Annotations)
for k, v := range app.Annotations {
ann[k] = v
}
for k, v := range route.Annotations {
ann[k] = v
}
return ann
}
func reqURL(req *http.Request) string {
if req.URL.Scheme == "" {
if req.TLS == nil {