Re: AngularJS + Ratpack File Upload

Wow, that's awesome! Thanks, Luke, totally above and beyond what I was expecting when I posted this. I understand most of your changes, but I do have a couple of questions.

I placed the config options in ratpack.properties because I didn't know where else to stick them. It didn't feel like the correct choice at the time and your changes confirm that it wasn't. Having the config in ratpack.groovy works fine in this case, but thinking ahead to a (hypothetical) real project with multiple developers working on it, I don't know how I feel about having config options there. Is there anything built in for arbitrary config files, or is that more of a "roll your own" kind of thing?

This next question probably stems from my lack of Guice knowledge, so please bear with me. What difference (if any) is there between using a module to bind a class to Scopes.SINGLETON and just annotating it with @Singleton? I had assumed I needed a module to take advantage of Guice, but I can see now that that's not the case. If I had two classes in the image package (e.g. ImageService and ImageResizer), would it make sense to have an ImageModule or would the @Singleton annotation still be sufficient?

Re: AngularJS + Ratpack File Upload

Administrator

Hi Sean,

You’re welcome.

I probably would use the launch config for this, as you can override via system properties in production and so forth. Not much would really change with the way the app was coded, you’d just move those vars “down” so you could read the initial values from the app. It would probably still make sense to do everything relative to the base dir as this is relative though. We are currently working on a better configuration story: https://github.com/ratpack/ratpack/issues/212

re Guice: In this case, there’s no difference. I changed the app to use what’s called a just-in-time (JIT) binding in Guice. It works in this case because the bindings for ImageService are very simple. Modules become useful for more complex bindings (e.g. you want to bind an implementation to an interface).

Ratpack only uses Guice JIT bindings for the registry returned by `Chain.getRegistry()`, which is what prefix(String, Closure) uses. This means that this will work…