apikotlinhandlerrequest-headersjavalin

Disabling Options method in Javalin 3.0


We are using Javalin in our kotlin application and we want to disable the options method from the handlers, We want to keep only get,post methods. below is the config code of Javalin

val app = Javalin.create {
          it.defaultContentType = "application/json"
          it.enableWebjars()
          it.addStaticFiles("", Location.CLASSPATH)
          it.enableCorsForAllOrigins()
          it.dynamicGzip = true
          it.showJavalinBanner = false
    }

I could not get 3.0 version documentation in the official website. is it in these lines to configure or some other place?


Solution

  • Consider adding an explicit handler for this method with default 405 response:

    app.options("/*") { throw MethodNotAllowedResponse() }