diff --git a/common.go b/common.go index 51dcbb63..5f9a2c56 100644 --- a/common.go +++ b/common.go @@ -21,5 +21,10 @@ import ( ) func UrlForFunction(m *Metadata) string { - return fmt.Sprintf("/fission-function/%v/%v", m.Name, m.Uid) + prefix := "/fission-function" + if len(m.Uid) > 0 { + return fmt.Sprintf("%v/%v/%v", prefix, m.Name, m.Uid) + } else { + return fmt.Sprintf("%v/%v", prefix, m.Name) + } } diff --git a/controller/watchApi.go b/controller/watchApi.go index 329b833b..b1c67d69 100644 --- a/controller/watchApi.go +++ b/controller/watchApi.go @@ -56,13 +56,7 @@ func (api *API) WatchApiCreate(w http.ResponseWriter, r *http.Request) { return } - function, err := api.FunctionStore.Get(&watch.Function) - if err != nil { - api.respondWithError(w, err) - return - } - - watch.Url = fission.UrlForFunction(&function.Metadata) + watch.Url = fission.UrlForFunction(&watch.Function) uid, err := api.WatchStore.Create(&watch) if err != nil { diff --git a/router/httpTriggers.go b/router/httpTriggers.go index 685efaf4..af8211d1 100644 --- a/router/httpTriggers.go +++ b/router/httpTriggers.go @@ -71,7 +71,7 @@ func (ts *HTTPTriggerSet) getRouter() *mux.Router { for _, function := range ts.functions { fh := &functionHandler{ fmap: ts.functionServiceMap, - Function: function.Metadata, + Function: fission.Metadata{Name: function.Metadata.Name}, poolmgr: ts.poolmgr, } muxRouter.HandleFunc(fission.UrlForFunction(&function.Metadata),