How to update Configuration before Play! loads?

31 views
Skip to first unread message

Erem Boto

unread,
Dec 12, 2017, 2:15:11 PM12/12/17
to Play Framework
Hello,

I'm using Guice for dependency injection in Play 2.5.x. I am trying to configure play.http.forwarded.trustedProxies using comma-separated values supplied by an env variable. However, lightbend Config does not allow comma-separated values from env variables to be interpreted as List[String], and so I can not get Play to recognize the set of comma-separated values I supply.

To solve this, I would like to get access to the typesafe Configuration object before Play initializes with it, and perform the env var parsing myself so that Play can interpret the value in Config as a List[String]. However, I can't find a good lifecycle hook for making this change so that it actually gets used by ForwardedHeaderHandler.

Any recommendations on how to accomplish this?

Cheers,
Erem

Thibault Meyer

unread,
Dec 13, 2017, 2:01:33 AM12/13/17
to Play Framework
Hi,

have you try to use the method indicated on the documentation to use value from environment variable ?

application.key = "value"
application.key = ${?APP_KEY}


If you just want use remote configuration (useful when you run your app on Docker or on multiple servers), I have created a plugin for Play 2.6 : https://github.com/payintech/play-remote-configuration

Greg Methvin

unread,
Dec 13, 2017, 3:37:15 PM12/13/17
to play-framework
You can also extend the GuiceApplicationLoader and add custom configuration there: https://www.playframework.com/documentation/2.6.x/ScalaDependencyInjection#Advanced:-Extending-the-GuiceApplicationLoader

--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/280d0e63-fcee-4682-9e9b-13007f96abac%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Greg Methvin
Tech Lead - Play Framework

Reply all
Reply to author
Forward
0 new messages