|
16 | 16 |
|
17 | 17 | package com.example.echo;
|
18 | 18 |
|
| 19 | +import com.google.api.control.ServiceManagementConfigFilter; |
| 20 | +import com.google.api.control.extensions.appengine.GoogleAppEngineControlFilter; |
| 21 | +import com.google.api.server.spi.EndpointsServlet; |
19 | 22 | import com.google.api.server.spi.guice.EndpointsModule;
|
20 | 23 | import com.google.common.collect.ImmutableList;
|
| 24 | +import com.google.inject.servlet.GuiceFilter; |
| 25 | +import java.util.HashMap; |
| 26 | +import java.util.Map; |
| 27 | +import javax.inject.Singleton; |
21 | 28 |
|
22 | 29 | // [START endpoints_module]
|
23 | 30 | public class EchoEndpointModule extends EndpointsModule {
|
24 | 31 | @Override
|
25 | 32 | public void configureServlets() {
|
| 33 | + super.configureServlets(); |
| 34 | + |
| 35 | + bind(ServiceManagementConfigFilter.class).in(Singleton.class); |
| 36 | + filter("/_ah/api/*").through(ServiceManagementConfigFilter.class); |
| 37 | + |
| 38 | + Map<String, String> apiController = new HashMap<String, String>(); |
| 39 | + apiController.put("endpoints.projectId", "YOUR-PROJECT-ID"); |
| 40 | + apiController.put("endpoints.serviceName", "YOUR-PROJECT-ID.appspot.com"); |
| 41 | + |
| 42 | + bind(GoogleAppEngineControlFilter.class).in(Singleton.class); |
| 43 | + filter("/_ah/api/*").through(GoogleAppEngineControlFilter.class, apiController); |
| 44 | + |
26 | 45 | bind(Echo.class).toInstance(new Echo());
|
27 | 46 | configureEndpoints("/_ah/api/*", ImmutableList.of(Echo.class));
|
28 |
| - super.configureServlets(); |
29 | 47 | }
|
30 | 48 | }
|
31 | 49 | // [END endpoints_module]
|
0 commit comments