-
Notifications
You must be signed in to change notification settings - Fork 5
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
Using midas within a Phoenix project #36
Comments
Midas' router is regular pattern matching so it would be possible to create a plug that only calls the router if no previous pattern matches. Would need some logic for converting to and from Plug.Conn and Midas Request/Response. I would be tempted to try and keep the routing all in one language and then writing controllers in a mix of Gleam and Elixir, or something like that. |
It's possible, the translation code between a Plug.Conn and two separate Request/Response data objects will be quite involved. Don't know how much complexity that will add, particularly around sessions/cookies. I could think a bit more about the translation code once I've nailed down the shape of the Request/Response, which might even be gleam Request/Responses depending on how we resolve the PR on gleam/http |
I think once Gleam HTTP has a request and response in it we can create a new Gleam Plug project which may offer these conversion functions if we decide that is the way to go. It may be easier to replicate a subset of the plug API in Gleam though. |
Thank you for the responses. I trust you both to assess the situation better than I can. For my part, I think I would be most comfortable doing little bits of Gleam within an Elixir project for the moment and it seems hard to do that without a way of interacting with Plugs from Gleam or handling entire requests in Gleam. Obviously it is early days and there is a lot to think through and other priorities but I wanted to raise the question to understand the current situation. Thanks! |
I think one route for adopting midas for me is if I could start it from within a mix/phoenix project and have it receive all HTTP requests and pass any that are unrecognised on to Phoenix. I'm unfamiliar with the lower levels of the HTTP stack in all of these projects so I've no idea how possible this might be.
From my perspective it would be the lowest friction way of introducing midas to a project that I already have. I was once keen for this kind of solution for migrating from Django to Phoenix obviously they are different tech stacks and I couldn't figure out how to make Phoenix proxy unrecognised requests over to the Django process so I ended up splitting all traffic at the nginx layer which is just a bit more hassle.
Anyway, I wanted to share the thought here as it would open up possibilities for trying Gleam & Midas more easily in some of my projects. Perhaps there are other downsides though and a clean break would be preferable for the development of the ecosystem.
Does it seem possible?
The text was updated successfully, but these errors were encountered: