Skip to content

Commit

Permalink
Merge pull request #18 from Moesif/feature-add-configuration-option
Browse files Browse the repository at this point in the history
Bump moesif-servlet and moesifapi dependencies
  • Loading branch information
dgilling authored Jun 30, 2019
2 parents e42b20b + 69367f5 commit 6ac8452
Show file tree
Hide file tree
Showing 13 changed files with 165 additions and 7 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ In `web.xml` file:
<param-name>debug</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>logBody</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>MoesifFilter</filter-name>
Expand Down Expand Up @@ -261,6 +265,10 @@ Edit the web.xml file to add your application id that you obtained from your Moe
<param-name>debug</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>logBody</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>MoesifFilter</filter-name>
Expand Down Expand Up @@ -324,6 +332,10 @@ Edit the web.xml file to add your application id that you obtained from your Moe
<param-name>debug</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>logBody</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>MoesifFilter</filter-name>
Expand Down Expand Up @@ -386,6 +398,10 @@ Edit the web.xml file to add your application id that you obtained from your Moe
<param-name>debug</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>logBody</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>MoesifFilter</filter-name>
Expand Down
4 changes: 4 additions & 0 deletions servlet-example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Edit the web.xml file to add your application id that you obtained from your Moe
<param-name>debug</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>logBody</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>MoesifFilter</filter-name>
Expand Down
4 changes: 2 additions & 2 deletions servlet-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<dependency>
<groupId>com.moesif.api</groupId>
<artifactId>moesifapi</artifactId>
<version>1.6.0</version>
<version>1.6.3</version>
</dependency>

<dependency>
Expand All @@ -41,7 +41,7 @@
<dependency>
<groupId>com.moesif.servlet</groupId>
<artifactId>moesif-servlet</artifactId>
<version>1.5.2</version>
<version>1.5.7</version>
</dependency>
</dependencies>

Expand Down
4 changes: 4 additions & 0 deletions servlet-example/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>logBody</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>MoesifFilter</filter-name>
Expand Down
4 changes: 4 additions & 0 deletions spark-servlet-example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Edit the web.xml file to add your application id that you obtained from your Moe
<param-name>debug</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>logBody</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>MoesifFilter</filter-name>
Expand Down
4 changes: 2 additions & 2 deletions spark-servlet-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@
<dependency>
<groupId>com.moesif.api</groupId>
<artifactId>moesifapi</artifactId>
<version>1.6.0</version>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>com.moesif.servlet</groupId>
<artifactId>moesif-servlet</artifactId>
<version>1.5.2</version>
<version>1.5.7</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
Expand Down
4 changes: 4 additions & 0 deletions spark-servlet-example/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>logBody</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter>
<filter-name>SparkFilter</filter-name>
Expand Down
52 changes: 52 additions & 0 deletions spring-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#### Spring Boot example

In order to run this example you will need to have Java 7+ and Maven installed.

Before starting, check that your maven version is 3.0.x or above:

```sh
mvn -v
```

1. Clone the repository

```sh
git clone https://github.com/Moesif/moesif-servlet
cd moesif-servlet
```

2. Update MyConfig to use your own Moesif ApplicationId
(Register for an account on [moesif.com](https://www.moesif.com))

```sh
vim spring-example/src/main/java/com/moesif/servlet/spring/MyConfig.java
```

3. Compile the example

```sh
cd spring-example
mvn clean install
```

4. Run spring-example (from the spring-example dir)

```sh
java -jar target/moesif-spring-example.jar
```

Alternatively:

```sh
mvn spring-boot:run
```


5. Go to `http://localhost:8080/greeting` or the port that Spring Boot is running on.

6. Set logBody flag to `false` in `MyConfig.java` file to remove logging request and response body to Moesif

```java
// Set flag to log request and response body
moesifFilter.setLogBody(true);
```
2 changes: 1 addition & 1 deletion spring-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<dependency>
<groupId>com.moesif.servlet</groupId>
<artifactId>moesif-servlet</artifactId>
<version>1.5.2</version>
<version>1.5.7</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public String getApiVersion(HttpServletRequest request, HttpServletResponse resp
}
};

return new MoesifFilter("Your Application Id", config, true);
MoesifFilter moesifFilter = new MoesifFilter("Your Application Id", config, true);

// Set flag to log request and response body
moesifFilter.setLogBody(true);

return moesifFilter;
}
}
65 changes: 65 additions & 0 deletions spring-mvc-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#### Spring MVC example

In order to run this example you will need to have Java 7+ and Maven installed.

Before starting, check that your maven version is 3.0.x or above:

```sh
mvn -v
```

1. Clone the repository

```sh
git clone https://github.com/Moesif/moesif-servlet
cd moesif-servlet
```

2. Update MyConfig to use your own Moesif ApplicationId
(Register for an account on [moesif.com](https://www.moesif.com))

```sh
vim spring-mvc-example/src/main/webapp/WEB-INF/web.xml
```

3. Run spring-mvc-example

```sh
cd spring-mvc-example
mvn jetty:run
```

4. Go to `http://localhost:8080/api/json`. In your Moesif Account, you should see event logged and monitored.

Shut it down manually with Ctrl-C.

In Spring MVC + XML configuration, you can register the filters via web.xml

In `web.xml` file:

```xml

<filter>
<filter-name>MoesifFilter</filter-name>
<filter-class>com.moesif.servlet.MoesifFilter</filter-class>
<init-param>
<param-name>application-id</param-name>
<param-value>your application id</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>logBody</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>MoesifFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>


```
You may have to override `onStartup()` to pass in the MoesifConfiguration object.
2 changes: 1 addition & 1 deletion spring-mvc-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<dependency>
<groupId>com.moesif.servlet</groupId>
<artifactId>moesif-servlet</artifactId>
<version>1.5.2</version>
<version>1.5.7</version>
</dependency>

</dependencies>
Expand Down
4 changes: 4 additions & 0 deletions spring-mvc-example/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
<param-name>debug</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>logBody</param-name>
<param-value>true</param-value>
</init-param>
</filter>

<filter-mapping>
Expand Down

0 comments on commit 6ac8452

Please sign in to comment.