redstone-dart / redstone

A metadata driven microframework for Dart.
http://redstone-dart.github.io/redstone
MIT License
342 stars 42 forks source link

Get fqdn in the request object #69

Closed sonoranDesert closed 9 years ago

sonoranDesert commented 9 years ago

Is there are way to get the fqdn or hostname requested by the client?

I see that I can look at app.request.url and app.request.url.path, but I need the actual server name / hostname from the request.

For example, if my redstone app serves a request for http://example.com/myresource, I know that app.request object has the "/myresource" string, but there is now way to get "example.com".

I need this so that I can do a 302 redirect if an old hostname is used in the request.

BTW I love redstone. It's by far the best Dart web framework I've used.

digitalfiz commented 9 years ago

You should be able to get it via:

app.request.headers.get('Host')
luizmineo commented 9 years ago

You can access the complete url through the shelf.Request object:

app.request.shelfRequest.requestedUri

Let me know if that helps

luizmineo commented 9 years ago

If you still have any problem or doubts, please let me know