Skip to content

Commit a867e79

Browse files
committed
adding cloud debugger sample : initial commit
1 parent d2129b6 commit a867e79

File tree

3 files changed

+136
-1
lines changed

3 files changed

+136
-1
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
6+
<modelVersion>4.0.0</modelVersion>
7+
<packaging>war</packaging>
8+
<version>1.0-SNAPSHOT</version>
9+
10+
<groupId>com.example.appengine</groupId>
11+
<artifactId>appengine-cloud-debugger</artifactId>
12+
13+
<properties>
14+
<failOnMissingWebXml>false</failOnMissingWebXml>
15+
</properties>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>com.google.appengine</groupId>
20+
<artifactId>appengine-api-1.0-sdk</artifactId>
21+
<version>1.9.53</version>
22+
</dependency>
23+
<dependency>
24+
<groupId>junit</groupId>
25+
<artifactId>junit</artifactId>
26+
<version>4.11</version>
27+
<scope>test</scope>
28+
</dependency>
29+
<dependency>
30+
<groupId>javax.servlet</groupId>
31+
<artifactId>javax.servlet-api</artifactId>
32+
<version>3.1.0</version>
33+
<scope>provided</scope>
34+
</dependency>
35+
</dependencies>
36+
37+
<build>
38+
<!-- for hot reload of the web application-->
39+
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes
40+
</outputDirectory>
41+
<plugins>
42+
<plugin>
43+
<groupId>org.apache.maven.plugins</groupId>
44+
<version>3.1</version>
45+
<artifactId>maven-compiler-plugin</artifactId>
46+
<configuration>
47+
<source>1.8</source>
48+
<target>1.8</target>
49+
</configuration>
50+
</plugin>
51+
<plugin>
52+
<groupId>org.apache.maven.plugins</groupId>
53+
<artifactId>maven-war-plugin</artifactId>
54+
<version>2.4</version>
55+
<configuration>
56+
<archiveClasses>true</archiveClasses>
57+
<webResources>
58+
<!-- in order to interpolate version from pom into appengine-web.xml -->
59+
<resource>
60+
<directory>${basedir}/src/main/webapp/WEB-INF</directory>
61+
<filtering>true</filtering>
62+
<targetPath>WEB-INF</targetPath>
63+
</resource>
64+
</webResources>
65+
</configuration>
66+
</plugin>
67+
68+
<plugin>
69+
<groupId>com.google.cloud.tools</groupId>
70+
<artifactId>appengine-maven-plugin</artifactId>
71+
<version>1.3.1</version>
72+
</plugin>
73+
</plugins>
74+
</build>
75+
</project>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* Copyright 2017 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
18+
package com.example.appengine.clouddebugger;
19+
20+
import javax.servlet.annotation.WebServlet;
21+
import javax.servlet.http.HttpServlet;
22+
import javax.servlet.http.HttpServletRequest;
23+
import javax.servlet.http.HttpServletResponse;
24+
25+
import java.io.IOException;
26+
import java.io.PrintWriter;
27+
28+
@WebServlet(value = "/")
29+
public class DebugServlet extends HttpServlet {
30+
31+
@Override
32+
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
33+
34+
String userAgent = request.getHeader("User-Agent");
35+
String displayName = "Browser";
36+
37+
if (userAgent != null) {
38+
if (userAgent.contains("Mozilla")) {
39+
displayName = "Firefox";
40+
} else if (userAgent.contains("Explorer")) {
41+
displayName = "Internet Explorer";
42+
} else if (userAgent.contains("Safari")) {
43+
displayName = "Safari";
44+
} else if (userAgent.contains("Chrome")) {
45+
displayName = "Chrome";
46+
} else if (userAgent.contains("Opera")) {
47+
displayName = "Opera";
48+
} else {
49+
displayName = userAgent;
50+
}
51+
}
52+
53+
response.setContentType("text/html");
54+
PrintWriter writer = response.getWriter();
55+
56+
writer.println("<html><body><h1>");
57+
writer.println("Hello " + displayName);
58+
writer.println("</h1></body></html>");
59+
}
60+
}

appengine-java8/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@
3838
<module>analytics</module>
3939
<module>appidentity</module>
4040
<!--<module>bigtable</module>--><!-- TODO(lesv) circle won't be happy yet -->
41+
<module>cloud-debugger</module>
4142
<module>cloudsql</module>
4243

4344
<module>datastore</module>
4445
<module>datastore-indexes</module>
4546
<module>datastore-indexes-exploding</module>
4647
<module>datastore-indexes-perfect</module>
47-
4848
<module>endpoints-v2-backend</module>
4949

5050
<module>firebase-event-proxy</module>

0 commit comments

Comments
 (0)