Skip to content

Commit b77cdcb

Browse files
author
Frank Natividad
committed
Moving filters
1 parent 8ccc6a4 commit b77cdcb

File tree

2 files changed

+8
-38
lines changed

2 files changed

+8
-38
lines changed

appengine/endpoints-frameworks-v2/guice-example/src/main/java/com/example/echo/EchoEndpointModule.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@
2424
import com.google.inject.servlet.GuiceFilter;
2525
import java.util.HashMap;
2626
import java.util.Map;
27+
import javax.inject.Singleton;
2728

2829
// [START endpoints_module]
2930
public class EchoEndpointModule extends EndpointsModule {
3031
@Override
3132
public void configureServlets() {
32-
filter("/_ah/api/*").through(GuiceFilter.class);
33-
3433
Map<String, String> apiController = new HashMap<String, String>();
3534
apiController.put("endpoints.projectId", "YOUR_PROJECT_ID");
3635
apiController.put("endpoints.serviceName", "YOUR_PROJECT_ID.appspot.com");
3736

37+
bind(ServiceManagementConfigFilter.class).in(Singleton.class);
3838
filter("/_ah/api/*").through(ServiceManagementConfigFilter.class);
39-
filter("/_ah/api/*").through(GoogleAppEngineControlFilter.class, apiController);
4039

41-
serve("/_ah/api/*").with(EndpointsServlet.class);
40+
bind(GoogleAppEngineControlFilter.class).in(Singleton.class);
41+
filter("/_ah/api/*").through(GoogleAppEngineControlFilter.class, apiController);
4242

4343
bind(Echo.class).toInstance(new Echo());
4444
configureEndpoints("/_ah/api/*", ImmutableList.of(Echo.class));

appengine/endpoints-frameworks-v2/guice-example/src/main/webapp/WEB-INF/web.xml

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@
1717
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
1818
<!-- Wrap the backend with Endpoints Frameworks v2. -->
1919
<!-- Route API method requests to the backend using Guice. -->
20-
<!--<filter>
20+
<filter>
2121
<filter-name>guiceFilter</filter-name>
2222
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
23-
</filter>-->
23+
</filter>
2424

2525
<!--
2626
URL Pattern /_ah/api/* instead of /* because a legacy v1 servlet uses
2727
the route /_ah/api/ and using /* will erronously use the legacy v1
2828
servlet instead of routing to your API.
2929
-->
30-
<!--<filter-mapping>
30+
<filter-mapping>
3131
<filter-name>guiceFilter</filter-name>
3232
<url-pattern>/_ah/api/*</url-pattern>
33-
</filter-mapping>-->
33+
</filter-mapping>
3434

3535
<listener>
3636
<listener-class>com.example.echo.EchoGuiceListener</listener-class>
@@ -40,34 +40,4 @@
4040
<welcome-file>index.html</welcome-file>
4141
</welcome-file-list>
4242

43-
<!--
44-
Add a filter that fetches the service config from service management.
45-
<filter>
46-
<filter-name>endpoints-api-configuration</filter-name>
47-
<filter-class>com.google.api.control.ServiceManagementConfigFilter</filter-class>
48-
</filter>
49-
-->
50-
<!-- Add a filter that performs Endpoints logging and monitoring
51-
<filter>
52-
<filter-name>endpoints-api-controller</filter-name>
53-
<filter-class>com.google.api.control.extensions.appengine.GoogleAppEngineControlFilter</filter-class>
54-
<init-param>
55-
<param-name>endpoints.projectId</param-name>
56-
<param-value>${endpoints.project.id}</param-value>
57-
</init-param>
58-
<init-param>
59-
<param-name>endpoints.serviceName</param-name>
60-
<param-value>${endpoints.project.id}.appspot.com</param-value>
61-
</init-param>
62-
</filter>
63-
64-
<filter-mapping>
65-
<filter-name>endpoints-api-configuration</filter-name>
66-
<servlet-name>EndpointsServlet</servlet-name>
67-
</filter-mapping>
68-
69-
<filter-mapping>
70-
<filter-name>endpoints-api-controller</filter-name>
71-
<servlet-name>EndpointsServlet</servlet-name>
72-
</filter-mapping>-->
7343
</web-app>

0 commit comments

Comments
 (0)