CORS and recap ( Aug 12, 2017 )

What's Javalin? Javalin is a very lightweight Java and Kotlin web framework which focuses on simplicity and Java/Kotlin interoperability. Read more on our landing page

CORS

Javalin 0.4.0 adds built-in CORS support with app.enableCorsForOrigin("origin") . There were also some breaking changes made to Jackson and the template-engines. If you want to configure Jackson now, you’ll have to call JavalinJacksonPlugin.configure() instead of just Jackson.configure() .

0.3.0 to 0.4.0 recap

Added simple file-upload api: app . post ( "/upload" ) { ctx -> ctx . uploadedFiles ( "files" ). forEach { ( contentType , content , name , extension ) -> FileUtils . copyInputStreamToFile ( content , File ( "upload/" + name )) } }

Added ctx.mapQueryParams() and ctx.mapFormParams() , which adds neat destructuring in Kotlin: app . post ( "/new-user" ) { ctx -> val ( name , email ) = ctx . mapFormParams ( "name" , "email" ) ?: throw MissingFormParamException () }

and , which adds neat destructuring in Kotlin: Added ctx.anyQueryParamNull() and ctx.anyFormParamNull() for Java devs who can’t destructure

and for Java devs who can’t destructure Added option to declare routes without paths, relying on the path() method: app . routes { path ( "users" ) { get ( userController: : getAllUsers ); post ( userController: : createUser ); path ( ":id" ) { get ( userController: : getUser ); patch ( userController: : updateUser ); delete ( userController: : deleteUser ); } } }

method: Added support for external static files via app.enableStaticFiles("/folder", Location.EXTERNAL)

app.start() and app.stop() are now synchronous methods ( app.awaitStart() and app.awaitStop() have been removed)

and are now synchronous methods ( and have been removed) Added @JvmStatic annotations, so INSTANCE can be omitted when calling configuration-methods from Java

annotations, so can be omitted when calling configuration-methods from Java Added option to dontIgnoreTrailingSlashes()

Added some convenience methods and overloads (like start(port) and render(templatePath) )

There were also other minor adjustments and bugfixes, see the news overview for a complete list.