package net.rebworks.lunchy;

import com.fasterxml.jackson.databind.SerializationFeature;
import io.dropwizard.Application;
import io.dropwizard.client.JerseyClientBuilder;
import io.dropwizard.setup.Environment;
import net.rebworks.lunchy.domain.io.HttpClient;
import net.rebworks.lunchy.injection.LunchyBinder;
import net.rebworks.lunchy.resources.LunchResource;

import javax.ws.rs.client.Client;
import java.text.DateFormat;

public class LunchyApplication extends Application<LunchyConfiguration> {
    public static void main(final String[] args) throws Exception {
        new LunchyApplication().run(args);
    }

    @Override
    public void run(final LunchyConfiguration lunchyConfiguration, final Environment environment) throws Exception {
        final Client client = new JerseyClientBuilder(environment).using(lunchyConfiguration.getJerseyClient())
                                                                  .build(getName());
        environment.jersey().register(new LunchyBinder(new HttpClient(client)));
        environment.jersey().register(LunchResource.class);
        environment.getObjectMapper().setDateFormat(DateFormat.getDateInstance());
        environment.getObjectMapper().configure(SerializationFeature.INDENT_OUTPUT, true);
    }

    @Override
    public String getName() {
        return "Lunchy";
    }
}

@@ -162,24 +162,192 @@
 entBuilder;%0A
+import io.dropwizard.configuration.EnvironmentVariableSubstitutor;%0Aimport io.dropwizard.configuration.SubstitutingSourceProvider;%0Aimport io.dropwizard.setup.Bootstrap;%0A
 import io.dr
@@ -775,32 +775,374 @@
 n(args);%0A    %7D%0A%0A
+    @Override%0A    public void initialize(final Bootstrap%3CLunchyConfiguration%3E bootstrap) %7B%0A        bootstrap.setConfigurationSourceProvider(new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(),%0A                                                                                new EnvironmentVariableSubstitutor()));%0A    %7D%0A%0A
     @Override%0A  

Add support for using environment variables for configuration