afb-api-ws: check that the ws-server API exist
authorJosé Bollo <jose.bollo@iot.bzh>
Wed, 30 Aug 2017 14:54:58 +0000 (16:54 +0200)
committerJosé Bollo <jose.bollo@iot.bzh>
Wed, 30 Aug 2017 14:54:58 +0000 (16:54 +0200)
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
src/afb-api-ws.c

index 07c8202..dffe126 100644 (file)
@@ -318,12 +318,19 @@ int afb_api_ws_add_server(const char *path, struct afb_apiset *apiset)
 {
        int rc;
        struct api_ws *apiws;
+       struct afb_api api;
 
        /* creates the ws api object */
        apiws = api_ws_make(path);
        if (apiws == NULL)
                goto error;
 
+       /* check api name */
+       if (afb_apiset_get(apiset, apiws->api, &api)) {
+               ERROR("Can't provide ws-server for %s: API %s doesn't exist", path, apiws->api);
+               goto error2;
+       }
+
        /* connect for serving */
        rc = api_ws_server_connect(apiws);
        if (rc < 0)