Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Moving filters
  • Loading branch information
Frank Natividad committed Sep 11, 2017
commit b77cdcb8acdd6f9880098981874b4c6662205321
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@
import com.google.inject.servlet.GuiceFilter;
import java.util.HashMap;
import java.util.Map;
import javax.inject.Singleton;

// [START endpoints_module]
public class EchoEndpointModule extends EndpointsModule {
@Override
public void configureServlets() {
filter("/_ah/api/*").through(GuiceFilter.class);

Map<String, String> apiController = new HashMap<String, String>();
apiController.put("endpoints.projectId", "YOUR_PROJECT_ID");
apiController.put("endpoints.serviceName", "YOUR_PROJECT_ID.appspot.com");

bind(ServiceManagementConfigFilter.class).in(Singleton.class);
filter("/_ah/api/*").through(ServiceManagementConfigFilter.class);
filter("/_ah/api/*").through(GoogleAppEngineControlFilter.class, apiController);

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

bind(Echo.class).toInstance(new Echo());
configureEndpoints("/_ah/api/*", ImmutableList.of(Echo.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
<!-- Wrap the backend with Endpoints Frameworks v2. -->
<!-- Route API method requests to the backend using Guice. -->
<!--<filter>
<filter>
<filter-name>guiceFilter</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>-->
</filter>

<!--
URL Pattern /_ah/api/* instead of /* because a legacy v1 servlet uses
the route /_ah/api/ and using /* will erronously use the legacy v1
servlet instead of routing to your API.
-->
<!--<filter-mapping>
<filter-mapping>
<filter-name>guiceFilter</filter-name>
<url-pattern>/_ah/api/*</url-pattern>
</filter-mapping>-->
</filter-mapping>

<listener>
<listener-class>com.example.echo.EchoGuiceListener</listener-class>
Expand All @@ -40,34 +40,4 @@
<welcome-file>index.html</welcome-file>
</welcome-file-list>

<!--
Add a filter that fetches the service config from service management.
<filter>
<filter-name>endpoints-api-configuration</filter-name>
<filter-class>com.google.api.control.ServiceManagementConfigFilter</filter-class>
</filter>
-->
<!-- Add a filter that performs Endpoints logging and monitoring
<filter>
<filter-name>endpoints-api-controller</filter-name>
<filter-class>com.google.api.control.extensions.appengine.GoogleAppEngineControlFilter</filter-class>
<init-param>
<param-name>endpoints.projectId</param-name>
<param-value>${endpoints.project.id}</param-value>
</init-param>
<init-param>
<param-name>endpoints.serviceName</param-name>
<param-value>${endpoints.project.id}.appspot.com</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>endpoints-api-configuration</filter-name>
<servlet-name>EndpointsServlet</servlet-name>
</filter-mapping>

<filter-mapping>
<filter-name>endpoints-api-controller</filter-name>
<servlet-name>EndpointsServlet</servlet-name>
</filter-mapping>-->
</web-app>