Search code examples
sinatracrystal-langkemal

How to process html form data with kemal and crystal


I want to get user input in an html form and use the data to populate a database table. Sinatra returns the form data in a hash, params. Can I do this with Kemal and Crystal?

Please note, I am in the process of learning Crystal, so this may not even be possible yet.

Thanks in advance for all answers. Meanwhile, I'm still digging:)


Solution

  • In Crystal, an HTTP::Handler receives an HTTP::Server::Context argument. Through this context, you can access the request and read the form data. The same also applies to Kemal, there is also a section in the guid: HTTP Parameters