tyntec / ktor-problem

Feature for Ktor (https://ktor.io) implementing RFC7807 (https://tools.ietf.org/html/rfc7807)
Apache License 2.0
11 stars 4 forks source link

Type mismatch when installing RFC7807Problems #2

Open Frieza93 opened 2 years ago

Frieza93 commented 2 years ago

Disclaimer: I am somethat new to Kotlin and Ktor, so I am not entirely sure this is actually a bug. Maybe I am making a mistake myself. However I have been trying to precisely follow the Readme and I am running into a problem when trying to install RFC7807Problems.

This is my Application.kt:

package com.example

import com.example.plugins.configureDependencyInjection
import com.example.plugins.configureRouting
import com.example.plugins.configureSecurity
import com.example.plugins.configureSerialization
import com.tyntec.ktor.problem.RFC7807Problems
import io.ktor.http.*
import io.ktor.server.application.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*

fun main() {
  embeddedServer(Netty, port = 8080, host = "0.0.0.0") {
        configureRouting()
        configureSerialization()
        configureSecurity()
        configureDependencyInjection()

        install(RFC7807Problems) {}
      }
      .start(wait = true)
}

At install(RFC7807Problems) {} I get:

Type mismatch. Required: Plugin<TypeVariable(P), TypeVariable(B), TypeVariable(F)> Found: RFC7807Problems.Feature

I'm working on Kotlin version 1.7.10 and Ktor version 2.0.3. Any chance there is a conflict resulting from the recent versions of Ktor and Kotlin?

michaelsauter commented 1 year ago

I'm running into the same issue. I think this is due to a breaking change in Ktor 2, see https://ktor.io/docs/eap/migrating-2.html#feature-plugin. https://github.com/tyntec/ktor-problem is built against Ktor 1.5.

bushwakko commented 1 year ago

Created a PR for this to work with ktor 2.2.2: https://github.com/tyntec/ktor-problem/pull/3