Dropwizard 0.8.0: serves for static assets from /

I want my server to serve static html files from /. In addition, css and js files must be sent with, /cssrespectively /js. All json data must be available in /api.

However, I get 404 for http://localhost:8080/or any other way.

I use the following parameter in the configuration file:

server:
  type: simple
  rootPath: /api/*

The application.initialize method looks like this:

@Override
public void initialize(io.dropwizard.setup.Bootstrap<MyConfiguration> bootstrap) {
    bootstrap.addBundle(new AssetsBundle("/assets/css", "/css", null, "css"));
    bootstrap.addBundle(new AssetsBundle("/assets/js", "/js", null, "js"));
    bootstrap.addBundle(new AssetsBundle("/assets/pages", "/", "index.html", "html"));
}
+4
source share
1 answer

( , , , -), , applicationContextPath, rootPath config:

server:
  type: simple
  rootPath: /api/*
  applicationContextPath: /

applicationContextPath "/application" , "/application/api/*". , , applicationContextPath: "/":

server:
  rootPath: /api/*
+6

Source: https://habr.com/ru/post/1584488/


All Articles