HeinrichApfelmus / threepenny-gui

GUI framework that uses the web browser as a display.
https://heinrichapfelmus.github.io/threepenny-gui/
Other
439 stars 77 forks source link

Custom resources #123

Closed ZacHilbert closed 7 years ago

ZacHilbert commented 8 years ago

I am interested in serving requests other than than /. For instance, I would like to request localhost:8023/custom.json and have server-side code generate the response. I considered just writing files to /static/custom.json, but having the request handled dynamically may have some advantages. In looking at the code, it seems I could mimic the approach that is used to server up Haskell.js (that is, implement a function like jsDriveCode :: Text, and then modify the routeResources function in Server.hs.) Does this seem like a sound approach?

A more robust solution would be to expose a function that registers the custom handler.

My use case for this is that I am using a jQuery library that consumes JSON and I would like to generate that JSON on the server on-demand from the client.

archaephyrryx commented 8 years ago

I don't really know if this is at all helpful, but have you looked into Aeson?

ZacHilbert commented 8 years ago

Yes. I used Aeson for generating/parsing JSON.

I've actually found away to do this where I can just skip generating JSON to pass to the client. I am able to to use FFI within event handlers to interact with the client side javascript objects.

HeinrichApfelmus commented 7 years ago

It appears to me that this issue is no longer relevant? Please reopen it if I am mistaken!