-
Notifications
You must be signed in to change notification settings - Fork 22
routing design #59
Comments
Interesting, yes, keying the routers on paths could help with automatically generating 405 responses. I would certainly be open to considering a PR that implemented this behavior! |
The only thing that I'm worried about is the performance when adding a larger amount of routes. On another note: These are just thoughts, I'm not trying to be a d*ck. ETR also has a fairly good implementation around libmicrohttpd, but I don't really understand his directory structure which makes the code hard to understand. Have you looked at that implementation or others? Maybe we could all work together on a project? |
The named option pattern was an excuse for me to have fun. I really like the way it works with CPR, but the invocation model is a bit different in that library. Originally, there was no explicit Anyway, I don't really write the header files for legibility. My highest priority for making the library usable is writing good documentation. You ask: What if you pass the same option twice? In truth, I'm not sure. MHD lets you do that, but in all honesty, I don't know what happens then. A nice thing to have would be to find a way to make passing in an option multiple times cause a compiler error…would need to think on how to make that work. Or at least throw a runtime exception, which is less ideal, but certainly better than allowing undefined behavior. I'm not sure what ETR is…can you provide a link? I'm not really familiar with any other C++ wrappers for MHD. I haven't researched this space well, as Luna originated from a very specific need at one of my previous companies, and I continue to develop it, because I continue to use it in a variety of projects. |
Oh wait I remember the other reason that most of the options are in the constructor: I didn’t want the caller to be able to change any of them after the server had been started, because those changes would have been no-ops. Could also make them parameters to |
These are 2 libs I researched for wrapping MHD: I think both are decently written. Just small things didn't feel right. For libhttpserver the directory structure makes no sense to me and for microrestd the flow just seems off. It calls handle on a request etc. I think it makes more sense to pass a request to a router or dispatcher and get a reponse like you are doing. Another 2 implementations that are really good: I dunno, I feel the world needs a standard GoTo C++ lightweight web/rest server :-) haha |
I couldn't agree more :D I don't want to require anything beyond what is strictly necessary, and MHD is, while far from perfect, delightfully lightweight. I want the syntax to be lightweight as well-my maxim is that it should be easy to use correctly, and difficult to use incorrectly. I fall short of the mark, I think, but I think I do better than most. Anyway, if you like where Luna is heading, help is always welcome! There's still ever so much to do… |
Hello,
I would like to discuss the routing implementation.
Currently it uses the method as key, but i think this is not preferred.
I made minimalistic implementation using the path as key (https://github.com/jdamme/swurf)
If you define a resource but you ask for an unsupported method it should return Method Not Allowed.
I think this is difficult to achieve with the current design. Would you consider something like this?
The text was updated successfully, but these errors were encountered: