ohler55 / agoo-c

Agoo webserver in C.
MIT License
146 stars 16 forks source link

Subdomain support #4

Closed daniesy closed 4 years ago

daniesy commented 5 years ago

Hey, I'm playing with the server and i quite like it (even though i haven't coded in C since uni). I have a question though: Is there any support for Sub-Domain Routing?

ohler55 commented 5 years ago

There is no support today. It would be possible to add it though. Basically a mapping of domains (user names for example) to different sub-directories under the root. Is that what you are looking for?

daniesy commented 5 years ago

Thanks for the fast answer! Laravel (PHP) has a good explanation and some examples here: https://laravel.com/docs/5.8/routing#route-group-sub-domain-routing

Route::domain('{account}.myapp.com')->group(function () {
   Route::get('user/{id}', function ($account, $id) {
     //
   });
});

TL;DR: they group routes from a wildcard subdomain and pass that subdomain's value as a parameter to the handler function.

ohler55 commented 5 years ago

So the only difference between what I proposed and the Laravel docs are that I suggested the path would be under root. removing that restriction would provide the same functionality I believe but different declaration syntax.

daniesy commented 5 years ago

Yep, you're right.

ohler55 commented 5 years ago

This feature will go into Agoo first and then immediately after into Agoo-C. They share most of the same code. I am working on it. :-)

ohler55 commented 5 years ago

Finally started working on subdomain support.

ohler55 commented 5 years ago

Please take a look at the domains branch. I still have to run some regression tests before releasing but I believe it is ready for testing. Unit tests in the Agoo repo pass.

ohler55 commented 4 years ago

No response. Feature added in v2.9.0.