- 
                Notifications
    You must be signed in to change notification settings 
- Fork 43
Basic Routing
        Frédéric Nieto edited this page Mar 4, 2020 
        ·
        2 revisions
      
    Basic routing happens like the Locations api from Ktor.
    @Response("A String Response")
    data class StringResponse(val str: String)inside the apiRouting as described in Setup
    get<Unit, StringResponse> { 
        respond(StringResponse("Hello World"))
    }    @Response("A String Response")
    data class StringResponse(val str: String)    @Path("string/{a}") // `@Path` works like the ktor Locations api `@Location`, if it is declared in a route, it will append the path to the one in the context
    data class StringParam(
        @PathParam("A simple String Param", PathParamStyle.matrix) val a: String, // You can provide a parameter style hint
        @QueryParam("Optional String") val optional: String? // Nullable Types are optional 
    )    get<StringParam, StringResponse> { params ->
        respond(StringResponse(params.a))
    }