Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give the possibility to create custom endpoints #118

Open
apiel opened this issue Aug 5, 2020 · 2 comments
Open

Give the possibility to create custom endpoints #118

apiel opened this issue Aug 5, 2020 · 2 comments

Comments

@apiel
Copy link

apiel commented Aug 5, 2020

Would it be possible to define some custom endpoint. I was trying something like:

  adapter->server.on("/hello", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send(200, "text/plain", "Hello, world");
  });

but I am getting the following error: error: 'AsyncWebServer WebThingAdapter::server' is private

In my firmware, I am using an http server for multiple features, for example to to pair the device with Amazon Alexa or to trigger OTA updates. When I try to add webthing-arduino, it is conflicting. The best would be to be able to re-use the server instance from webthing-arduino.

@apiel apiel closed this as completed Aug 5, 2020
@apiel apiel reopened this Aug 5, 2020
@mrstegeman
Copy link
Contributor

We actually have this capability in all of our other webthing libraries. However, it's difficult to do so with this one, since essentially each platform uses a different web server library. It's not straightforward to write an agnostic interface for adding new routes. We could make the server member public, I suppose, but that feels so unfinished.

@apiel
Copy link
Author

apiel commented Aug 5, 2020

Right now the only way I found is to create 2 servers. One for the webthings adapter on port 8080 and one using ESPAsyncWebServer on port 80. Would be amazing to be able to have both on port 80. Of course making server public could bring inconsistency if users overwrite some endpoints defined by webthings, but it would be an easy way to start...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants