package com.eogren.link_checker.service_layer;

import com.eogren.link_checker.service_layer.data.InMemoryRootPageRepository;
import com.eogren.link_checker.service_layer.resources.RootPageResource;
import io.dropwizard.Application;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;

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

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

    @Override
    public void initialize(Bootstrap<LinkCheckerConfiguration> bootstrap) {
    }

    @Override
    public void run(LinkCheckerConfiguration config, Environment environment) {
        environment.jersey().register(new RootPageResource(new InMemoryRootPageRepository()));
    }
}

@@ -303,16 +303,174 @@
 ronment;
+%0Aimport org.eclipse.jetty.servlets.CrossOriginFilter;%0A%0Aimport javax.servlet.DispatcherType;%0Aimport javax.servlet.FilterRegistration;%0Aimport java.util.EnumSet;
 %0A%0Apublic
@@ -1032,16 +1032,234 @@
 ry()));%0A
+        final FilterRegistration.Dynamic cors = environment.servlets().addFilter(%22crossOriginRequests%22, CrossOriginFilter.class);%0A        cors.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, %22/*%22);%0A
     %7D%0A%7D%0A

add CORS headers to requests