ktorio / ktor-init-tools

ktor project generator web page and IDEA plugin
https://start.ktor.io
Other
40 stars 20 forks source link

Generated code for HTTP plugins is broken #56

Open thedjdoorn opened 2 years ago

thedjdoorn commented 2 years ago

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