ktorio / ktor-init-tools

ktor project generator web page and IDEA plugin

Home Page:https://start.ktor.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generated code for HTTP plugins is broken

thedjdoorn opened this issue · 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