dropwizard

How to log JSON responses in Dropwizard (Jersey)

拟墨画扇 提交于 2019-12-05 03:45:25
I would like to know how one would configure Dropwizard to log the JSON response. In dropwizard 0.8.1 (also tried in 0.9.0-SNAPSHOT), add to Application.run(...) : import java.util.logging.Logger; import org.glassfish.jersey.filter.LoggingFilter; ... public void run(MyApplicationConfiguration conf, Environment env) throws Exception { // do your stuff and then add LoggingFilter env.jersey().register(new LoggingFilter( Logger.getLogger(LoggingFilter.class.getName()), true) ); } To configure logger, add in your configuration file (e.g.: conf.yml ): logging: loggers: org.glassfish.jersey.filter

How to deploy an angularjs application frontend with Nginx and dropwizard

佐手、 提交于 2019-12-05 01:28:45
I'm developing an application using angularjs application frontend having as backend dropwizard. I'm planning to use Nginx as gateway for the backend dropwizard server and as an asset server (images and maybe the angularjs application). My question is what is the best strategy for deployement: Bundling angularjs with the dropwizard backend and using nginx as frontend? Deploying angularjs application on the nginx server? Thanks in advance, Juan P. Prado Following this answer You can use this nginx configuration file in order to proxy the Dropwizard application inside your server from port 8080

Bean validation in DropWizard with custom Json output

☆樱花仙子☆ 提交于 2019-12-04 20:43:11
I have developing a webservice with a variety of Rest functions. I would like to use the standard @Valid annotation to validate my beans. I do however want to modify the the output json error. Error messages from the validation is currently formatted like this: { "errors": [ "someString size must be between 0 and 140", "anotherString cannot contain numbers" ] } I do however want the error messages to be formatted like this: { "errors": [{ "someString": "size must be between 0 and 140" }, { "anotherString": "cannot contain numbers" } ] } or { "errors": [{ "field": "someString" "error": "size

Dropwizard hot deployment

旧街凉风 提交于 2019-12-04 19:09:53
问题 I'm looking for a simple to use system in Java which creates a REST service for me. So I found dropwizard but as far as I can use google it turns out it lacks hot deployment although jetty is able to do so. When using the maven-shade-plugin it takes at least 10 seconds to build the thing. Also my IDE reports that it cannot use compile on save feature (aka hot deployment) when the shade-plugin is involved. Can I use hotdeployment somehow? Or what can I use instead? Update : If nothing will fix

How to make @JsonSnakeCase the default for configuration in Dropwizard

僤鯓⒐⒋嵵緔 提交于 2019-12-04 17:49:48
问题 How will I configure jackson to use snake case in dropwizard instead of putting @JsonSnakeCase in every class ? 回答1: And finally am able to find the answer.. Just add below cofiguration. environment.getObjectMapperFactory().setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES) 回答2: Just add this following line in your run() method environment.getObjectMapper().setPropertyNamingStrategy( PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);

Does Dropwizard Support Servlet 3 Asynchronous Servlets?

你说的曾经没有我的故事 提交于 2019-12-04 12:54:25
Does Dropwizard support Servlet 3 asynchronous servlets? If not, is it on the roadmap at any time in the near future? It uses Jetty 8, which supports Servlet 3.0. Jersey (and JAX-RS) doesn't have any support for this, but it's forthcoming in JAX-RS 2.0 (and Jersey 2.0). Dropwizard doesn't add anything special, but when Jersey 2.0 ships, the next major Dropwizard release will very likely include it. You can use https://github.com/jetty-project/jetty-eventsource-servlet . Read wiki for how to impl Servlet and EventSource In your DW Service implementation you add your SSE servlet environment

Custom Jetty Filters in Dropwizard

和自甴很熟 提交于 2019-12-04 10:53:06
I'm attempting to add a custom header filter in my Dropwizard instance to check to see if the request's version is synced to the Dropwizard instance's version. I see you can use FilterBuilder to add jetty CrossOriginFilters . However, I am having trouble figuring out how to set a custom filter. Thanks Via the Environment class. https://dropwizard.github.io/dropwizard/manual/core.html#environments @Override public void run(MyApplicationConfiguration configuration, Environment environment) { environment.servlets().addFilter("Custom-Filter-Name", new MyCustomFilter()).addMappingForUrlPatterns

Spring configurable, high performance, metered http client instances

谁说胖子不能爱 提交于 2019-12-04 10:10:31
Coming from DropWizard I am used to its HttpClientConfiguration and I am baffled that in Spring Boot I cannot find some support for controlling in a similar manner http clients instances to be used, by RestTemplates for example. To work in production the underlying client implementation should be high performance (e.g. non blocking io, with connection reuse and pooling). Then I need to set timeouts or authentication, possibly metrics gathering, cookie settings, SSL certificates settings. All of the above should be easy to set up in different variants for different instances to be used in

Integrate Apache Shiro Security Library with Dropwizard based JAX-RS application

心已入冬 提交于 2019-12-04 08:45:10
问题 I am trying to change Dropwizard to support Shiro. I have read documentation and am little puzzled. I would like to utilize Shiro in conjunction with form login authentication and Apache Shiro Annotations. I think that I need to use Jersey Filters to support Shiro. Is this the correct way to support Shiro annotations at Jersey instead of classic Shiro Filter approach? Since Jersey Filters have decent access to resources with annotations, it seems perfect for me to use annotations. I rather

How to implement statistics using dropwizard metrics and spring-mvc

这一生的挚爱 提交于 2019-12-04 07:37:34
I am having about 20 APIs and I want to implement statistics like execution time, responses count .. for each API. After doing some research, I came to know that dropwizard metrics is the best approach for implementing such functionalities. I am using Spring MVC framework (non-bootable). Can anybody please suggest me how to integrate Metrics to Spring MVC framework? If possible please provide any code as a reference. You can use Metrics for Spring . Here's a github link , which explains how to integrate it with Spring MVC. The metrics-spring module integrates Dropwizard Metrics library with