Spring Boot with Additional MIME Content Type

Submitted by Dickens A S on Sun, 11/03/2019 - 09:35

Spring boot provides default list of MIME content types from the below class

impot org.springframework.boot.web.server.MimeMappings;

Additional content types can be added using below example code for WebAssembly content type

@Configuration
class AppConfig : WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> {
   override fun customize(factory:ConfigurableServletWebServerFactory ) {
       var mappings:MimeMappings = MimeMappings(MimeMappings.DEFAULT);
       mappings.add("wasm", "application/wasm;charset=utf-8");
       factory.setMimeMappings(mappings);
   }
}

with above code a spring boot application can serve WebAssembly binaries 

End Of Article

Add new comment