mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Expose route and app models to RunnerCall for extensions (alternative 2) (#880)
This commit is contained in:
committed by
Gerardo Viedma
parent
563a4576ef
commit
8df8ed6360
@@ -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 {
|
||||
|
||||
@@ -126,6 +126,9 @@ type Call struct {
|
||||
// Config is the set of configuration variables for the call
|
||||
Config Config `json:"config,omitempty" db:"-"`
|
||||
|
||||
// Annotations is the set of annotations for the app/route of the call.
|
||||
Annotations Annotations `json:"annotations,omitempty" db:"-"`
|
||||
|
||||
// Headers are headers from the request that created this call
|
||||
Headers http.Header `json:"headers,omitempty" db:"-"`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user