Given that it's such a common need to generate an absolute uri
including the hostname (to be used in email links, redirect urls for
extenal apis, etc.) and there's no generic, reliable way to deduce it
on the fly, don't you think it'd make sense if the core reserved the
following symbols and contributed some sensible defaults, such as:
public static void
contributeFactoryDefaults(MappedConfiguration<String, String>
configuration) {
String hostname = null;
try {
hostname = System.getenv("HOSTNAME");
} catch (Exception e) {
}
if (hostname == null) hostname = "localhost"; // or
InetAddress.getLocalHost().getHostName()
configuration.add(HostSymbols.HOSTNAME, hostname);
configuration.add(HostSymbols.BASEURI, "http://" + hostname);
}
Sure it's easy to do this in your own application, but if external
libraries require it (I'm working on a drop-in Oauth module), they
would have to use some custom symbol names especially if they
contribute factory defaults so they wouldn't step on each other. Easy
addition, no drawbacks or what do you think? I'll open an issue if you
agree.
Kalle
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]