ktor-init-tools icon indicating copy to clipboard operation
ktor-init-tools copied to clipboard

Generated code for HTTP plugins is broken

Open thedjdoorn opened this issue 2 years ago • 0 comments

When one picks the HSTS and CORS plugins (IDEA plugin or online generator, doesn't matter), plugins/HTTP.kt will not compile. This is due to two issues:

Missing imports

io.ktor.server.plugins.hsts.* and io.ktor.server.plugins.cors.routing.* should also be imported, with the latter being quite important, since someone might not read the documentation and import the deprecated option (cors.CORS).

Out-of-date code

The install(CORS) call contains the following:

        method(HttpMethod.Options)
        method(HttpMethod.Put)
        method(HttpMethod.Delete)
        method(HttpMethod.Patch)
        header(HttpHeaders.Authorization)
        header("MyCustomHeader")

This doesn't work. method should be allowMethod, and header should be allowHeader

thedjdoorn avatar May 02 '22 17:05 thedjdoorn