File tree Expand file tree Collapse file tree 5 files changed +37
-37
lines changed
appengine-java8/endpoints-v2-guice
appengine/endpoints-frameworks-v2/guice-example
src/main/java/com/example/echo Expand file tree Collapse file tree 5 files changed +37
-37
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,8 @@ To add the project ID:
17
17
0 . For ` <endpoints.project.id> ` , replace the value ` YOUR_PROJECT_ID ` with
18
18
your project ID.
19
19
20
- 0 . Edit the file ` src/main/java/com/example/echo/Echo.java ` .
20
+ 0 . Edit the file ` src/main/java/com/example/echo/Echo.java ` and
21
+ ` src/main/java/com/example/echo/EchoEndpointModule.java ` .
21
22
22
23
0 . Replace the value ` YOUR-PROJECT-ID ` with your project ID.
23
24
@@ -82,7 +83,8 @@ You will get a 200 response with the following data:
82
83
0 . For ` def projectId = 'YOUR_PROJECT_ID' ` , replace the value ` YOUR_PROJECT_ID `
83
84
with your project ID.
84
85
85
- 0 . Edit the file `src/main/java/com/example/echo/Echo.java
86
+ 0 . Edit the file ` src/main/java/com/example/echo/Echo.java ` and
87
+ ` src/main/java/com/example/echo/EchoEndpointModule.java ` .
86
88
87
89
0 . Replace the value ` YOUR-PROJECT-ID ` with your project ID.
88
90
Original file line number Diff line number Diff line change 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
47
}
Original file line number Diff line number Diff line change 22
22
<filter-class >com.google.inject.servlet.GuiceFilter</filter-class >
23
23
</filter >
24
24
25
+ <!--
26
+ URL Pattern /_ah/api/* instead of /* because a legacy v1 servlet uses
27
+ the route /_ah/api/ and using /* will erronously use the legacy v1
28
+ servlet instead of routing to your API.
29
+ -->
25
30
<filter-mapping >
26
31
<filter-name >guiceFilter</filter-name >
27
32
<url-pattern >/_ah/api/*</url-pattern >
35
40
<welcome-file >index.html</welcome-file >
36
41
</welcome-file-list >
37
42
38
- <!-- Add a filter that fetches the service config from service management. -->
39
- <filter >
40
- <filter-name >endpoints-api-configuration</filter-name >
41
- <filter-class >com.google.api.control.ServiceManagementConfigFilter</filter-class >
42
- </filter >
43
-
44
- <!-- Add a filter that performs Endpoints logging and monitoring. -->
45
- <filter >
46
- <filter-name >endpoints-api-controller</filter-name >
47
- <filter-class >com.google.api.control.extensions.appengine.GoogleAppEngineControlFilter</filter-class >
48
- <init-param >
49
- <param-name >endpoints.projectId</param-name >
50
- <param-value >${endpoints.project.id}</param-value >
51
- </init-param >
52
- <init-param >
53
- <param-name >endpoints.serviceName</param-name >
54
- <param-value >${endpoints.project.id}.appspot.com</param-value >
55
- </init-param >
56
- </filter >
57
-
58
- <filter-mapping >
59
- <filter-name >endpoints-api-configuration</filter-name >
60
- <servlet-name >EndpointsServlet</servlet-name >
61
- </filter-mapping >
62
-
63
- <filter-mapping >
64
- <filter-name >endpoints-api-controller</filter-name >
65
- <servlet-name >EndpointsServlet</servlet-name >
66
- </filter-mapping >
67
43
</web-app >
Original file line number Diff line number Diff line change @@ -17,7 +17,8 @@ To add the project ID:
17
17
0 . For ` <endpoints.project.id> ` , replace the value ` YOUR_PROJECT_ID ` with
18
18
your project ID.
19
19
20
- 0 . Edit the file ` src/main/java/com/example/echo/Echo.java ` .
20
+ 0 . Edit the file ` src/main/java/com/example/echo/Echo.java ` and
21
+ ` src/main/java/com/example/echo/EchoEndpointModule.java ` .
21
22
22
23
0 . Replace the value ` YOUR-PROJECT-ID ` with your project ID.
23
24
@@ -82,7 +83,8 @@ You will get a 200 response with the following data:
82
83
0 . For ` def projectId = 'YOUR_PROJECT_ID' ` , replace the value ` YOUR_PROJECT_ID `
83
84
with your project ID.
84
85
85
- 0 . Edit the file `src/main/java/com/example/echo/Echo.java
86
+ 0 . Edit the file ` src/main/java/com/example/echo/Echo.java ` and
87
+ ` src/main/java/com/example/echo/EchoEndpointModule.java `
86
88
87
89
0 . Replace the value ` YOUR-PROJECT-ID ` with your project ID.
88
90
Original file line number Diff line number Diff line change 30
30
public class EchoEndpointModule extends EndpointsModule {
31
31
@ Override
32
32
public void configureServlets () {
33
- Map <String , String > apiController = new HashMap <String , String >();
34
- apiController .put ("endpoints.projectId" , "YOUR_PROJECT_ID" );
35
- apiController .put ("endpoints.serviceName" , "YOUR_PROJECT_ID.appspot.com" );
33
+ super .configureServlets ();
36
34
37
35
bind (ServiceManagementConfigFilter .class ).in (Singleton .class );
38
36
filter ("/_ah/api/*" ).through (ServiceManagementConfigFilter .class );
39
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
+
40
42
bind (GoogleAppEngineControlFilter .class ).in (Singleton .class );
41
43
filter ("/_ah/api/*" ).through (GoogleAppEngineControlFilter .class , apiController );
42
44
43
45
bind (Echo .class ).toInstance (new Echo ());
44
46
configureEndpoints ("/_ah/api/*" , ImmutableList .of (Echo .class ));
45
- super .configureServlets ();
46
47
}
47
48
}
48
49
// [END endpoints_module]
You can’t perform that action at this time.
0 commit comments