nning / david

CoAP server with Rack interface.
MIT License
37 stars 11 forks source link

.well-known/core not available using sinatra #6

Open felixletkemann opened 7 years ago

felixletkemann commented 7 years ago

While the readme of David lists sinatra as one of the frameworks which are compatible with david, I could not get david to work with sinatra so far. Adding the david gem (together with cbor) will make rackup talk over coap just as desired. Unfortunately, there is no .well-known/core route to tell the CoAP client what is available. Also, I can not use the discoverable option in my controller, since the "discoverable" option is depending on the railties. In order to be compatible with all the other frameworks, there should be a way to make the .well-known/core route available. Do you have any working example with sinatra and david?

felixletkemann commented 7 years ago

Since accessing the sinatra routes over CoAP, the workaround is the following:

  post '/blub/hallo' do
    puts "\n\n\n\n"
    puts params.inspect
    puts "\n\n\n\n"
    'Test Antwort'
  end

  get '/.well-known/core' do
    content_type 'application/link-format'
    '</blub/hallo>;sh="/t";n="Hallo",
    </blub/zweitertest>;sh="/l";ct=41;n="HalloTest"'
  end
nning commented 7 years ago

Automatically generating .well-known/core is currently only supported in Rails. I will keep this issue open as feature request.

nning commented 7 years ago

Would you like to add this feature?

felixletkemann commented 7 years ago

Maybe I can add this feature as soon as I get a little deeper into coap and into the internal logic of the david gem. At the moment, I would prefer just adding a few lines of code to the documentation that describe how to use david with sinatra. bildschirmfoto 2017-07-28 um 11 31 57 bildschirmfoto 2017-07-28 um 11 32 52

mcr commented 6 years ago

I'm looking at this now from a different point of view: making sure that rspec requests can get from /.well-known/core. I already changed how to link list was created in my pull request. I've submitted issue #10 about this.