david icon indicating copy to clipboard operation
david copied to clipboard

.well-known/core not available using sinatra

Open felixletkemann opened this issue 8 years ago • 5 comments

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 avatar Jul 24 '17 13:07 felixletkemann

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

felixletkemann avatar Jul 24 '17 13:07 felixletkemann

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

nning avatar Jul 27 '17 14:07 nning

Would you like to add this feature?

nning avatar Jul 27 '17 15:07 nning

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

felixletkemann avatar Jul 28 '17 09:07 felixletkemann

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.

mcr avatar Feb 07 '18 19:02 mcr