eclipse-thingweb / eclipse-thingweb/node-wot

Better support for `subprotocols`

Open
#555 7 comments 1 reaction 0 assignees View on GitHub
core enhancement
Dominant language
TypeScript
Stars
192
Forks
100
Avg merge
3d 2h
Merged PRs (30d)
6

Description

Currently, node-wot only supports client-factories attached to a specific scheme, therefore delegating the subprotocol selection logic to the binding implementation. This means that the "father" protocol binding has to manually select the subprotocol logic when a particular operation is called. Maybe an example can help here. Suppose we a new subprotocol Y for the HTTP protocol. Implementers have two choices:
1. Create a new protocol binding folder `binding-sub-y`: In this case, that subprotocol implementation can't be used in conjunction with HTTP, cause they both use the same `scheme`
2. Implement the logic inside the `http-binding`.

I would consider as a real option only `2`, therefore continuing on that path the implementer has now to add the sub-protocol logic inside our `http-client`and `https-client`. Taking one operation for simplicity the code will look like something like this:
```ts
public async readResource(form: HttpForm): Promise {
if(form.subprotocol === "Y"){
return readResourceWithSubprotocolY(form);
}
/* Current HTTP client implementation */
}
```
As you can imagine this will increase the complexity of the client as the subprotocol implementations list grow. Should we move this responsibility to the core? In other words, should we allow protocol-bindings implementations to refer to a specific subprotocol?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.