Giter VIP home page Giter VIP logo

Comments (4)

Wicpar avatar Wicpar commented on May 22, 2024

I'll look at it later today if i have time.
If you want to display the trace you can add the trace as described at the bottom of the ktor route documentation. https://ktor.io/servers/features/routing.html

Also be careful with authenticated routes, the definitions could clash, this was the reason i originally didn't create these variants...

from ktor-openapi-generator.

Wicpar avatar Wicpar commented on May 22, 2024

Oh right, something similar happened to someone else also, make sure that the content type is specified in the tests, the routes are defined on specific content types to allow handling of multiple content types on the same route.

from ktor-openapi-generator.

plannigan avatar plannigan commented on May 22, 2024

Setting the content type resolved the issue and now all the test cases pass. So I'll close this issue.

I'll take a look at the auth routes. If the generics does cause a problem, would you be open to something like auth{METHOD}()? It's subjective, but I feel like

route("/some/route") {
    post<SomeResponse, SomeBody> {
            body ->
        println(body)
        respond(SomeResponse("hello"))
    }
    authPost<SomeResponse, SomeBody, SomeAuth> {
            body ->
        println(body)
        respond(SomeResponse("hello"))
    }
}

route("/some/route/{foo}") {
    post<SomeParam, SomeResponse, SomeBody> {
            param, body ->
        println(param)
        println(body)
        respond(SomeResponse("hello"))
    }
    authPost<SomeParam, SomeResponse, SomeBody, SomeAuth> {
            param, body ->
        println(param)
        println(body)
        respond(SomeResponse("hello"))
    }
}

looks better than

route("/some/route") {
    post<Unit, SomeResponse, SomeBody> {
            body ->
        println(body)
        respond(SomeResponse("hello"))
    }
    post<Unit, SomeResponse, SomeBody, SomeAuth> {
            body ->
        println(body)
        respond(SomeResponse("hello"))
    }
}

route("/some/route/{foo}") {
    post<SomeParam, SomeResponse, SomeBody> {
            param, body ->
        println(param)
        println(body)
        respond(SomeResponse("hello"))
    }
    post<SomeParam, SomeResponse, SomeBody, SomeAuth> {
            param, body ->
        println(param)
        println(body)
        respond(SomeResponse("hello"))
    }
}

from ktor-openapi-generator.

Wicpar avatar Wicpar commented on May 22, 2024

The plan is to eventually transition to an injection based route configuration #10
It will still be computed during init for no runtime impact and allow for quite a bit more flexibility and a cleaner syntax.

from ktor-openapi-generator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.