That does, thanks!

On Thursday, May 7, 2020 at 10:23:58 PM UTC-7, Dimas Guardado wrote:
>
> One way to implement this is to mount the application context at "/" and 
> the jersey root at "/application", then registering a redirect servlet at 
> "/"
>
> ```config.yml
> server:
>   type: simple
>   applicationContextPath: /
>   rootPath: /application
>   adminContextPath: /admin
> ```
>
> ```YourApplication.java
>     @Override
>     public void run(final SampleContextConfiguration configuration,
>                     final Environment environment) {
>         environment.servlets().addServlet("root-redirect", new 
> HttpServlet() {
>             @Override
>             protected void doGet(HttpServletRequest req, 
> HttpServletResponse resp) throws IOException {
>                 resp.sendRedirect("/application");
>             }
>         }).addMapping(""); // empty string maps to root path only, "/" 
> will map to any unmapped path
>     }
> ```
>
> Does that do what you're looking for?
>
> -Dimas
>
> On Tuesday, May 5, 2020 at 5:36:11 PM UTC-7, Joe Barnett wrote:
>>
>> Hello,
>>
>> We're using SimpleServerFactory and running on heroku, and would like the 
>> root url (eg https://my-dropwizard-app.herokuapp.com ) to redirect to 
>> the applicationContextPath (eg 
>> https://my-dropwizard-app.herokuapp.com/application ) rather than always 
>> return a 404.  It looks like this can be done by subclassing 
>> SimpleServerFactory and overriding the `build` method to copy/paste 
>> everything with an additional `ContextRoutingHandler` map entry that 
>> handles "/" with a Handler that returns a 302 redirect to the 
>> applicationContextPath, but would prefer to not have to duplicate the 
>> `build` method logic.  Is there a hook that we're missing that would solve 
>> this issue differently?  If not, would it make sense to add a way for 
>> applications to configure the SimpleServerFactory to handle the root URI?
>>
>> Thanks,
>> -Joe
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dropwizard-user/d040e1a1-abf4-48bc-be4b-9831cc728060%40googlegroups.com.

Reply via email to