How to configure Undertow to add encoding to text / content types?

I have a software running Undertow server (does not work as part of any container).

My static resources served with the ResourceHander in the PathResourceManager are UTF-8 encoded, but the mime type sent by the PathResourceManager does not contain an encoding.

I would rather not bend to creating a whole new MimeMappings table and setting it up.

Is it possible to use a handler to add charset to responses with CONTENT-TYPE starting with `text / '?

+1
source share
1 answer

I did this in my code:

 handler = path() .addPrefixPath("/", resource(new FileResourceManager(webStaticDir, 1024)) .setMimeMappings(MimeMappings.builder(true) .addMapping("html", "text/html;charset=utf-8") .build())); 

Perhaps you can adapt it to your situation.

+1
source

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


All Articles