|
| 1 | +/* |
| 2 | + * Jooby https://jooby.io |
| 3 | + * Apache License Version 2.0 https://jooby.io/LICENSE.txt |
| 4 | + * Copyright 2014 Edgar Espina |
| 5 | + */ |
| 6 | +package i3490 |
| 7 | + |
| 8 | +import io.jooby.Context |
| 9 | +import io.jooby.annotation.* |
| 10 | +import java.io.IOException |
| 11 | +import java.util.concurrent.CompletableFuture |
| 12 | +import kotlinx.coroutines.delay |
| 13 | + |
| 14 | +@Path("/") |
| 15 | +class C3490 { |
| 16 | + @GET |
| 17 | + suspend fun sayHi(@QueryParam n: String?, @QueryParam bit: String?): String { |
| 18 | + return Thread.currentThread().name + ": " + n + ": " + bit |
| 19 | + } |
| 20 | + |
| 21 | + @GET("/bye") |
| 22 | + suspend fun sayGoodBye(@QueryParam n: String): String { |
| 23 | + val from = Thread.currentThread().name |
| 24 | + delay(100) |
| 25 | + return from + ":" + Thread.currentThread().name + ": " + n |
| 26 | + } |
| 27 | + |
| 28 | + @GET("/completable") |
| 29 | + fun completable(): CompletableFuture<String> { |
| 30 | + val from = Thread.currentThread().name |
| 31 | + return CompletableFuture.supplyAsync { from + ": " + Thread.currentThread().name + ": Async" } |
| 32 | + } |
| 33 | + |
| 34 | + @Throws(IOException::class) |
| 35 | + @GET("/fo\"o") |
| 36 | + fun foo(ctx: Context) { |
| 37 | + ctx.send("fff") |
| 38 | + } |
| 39 | + |
| 40 | + @GET("/bean") fun bean(@BindParam bean: Bean3490) = bean |
| 41 | + |
| 42 | + @GET("/gen") fun gen(@BindParam bean: Bean3490): List<String> = listOf() |
| 43 | + |
| 44 | + @GET("/gene") fun <E> genE(@BindParam bean: Bean3490): List<E> = listOf() |
| 45 | + |
| 46 | + @GET("/genlist") fun <E> genE(@QueryParam bean: List<E>): List<E> = listOf() |
| 47 | + |
| 48 | + @GET("/context") fun contextAttr(@ContextParam attributes: Map<String, Any>) = attributes |
| 49 | + |
| 50 | + @GET("/box") fun box(@QueryParam box: Box3490<Int>) = box |
| 51 | + |
| 52 | + @GET("/list") |
| 53 | + fun box(@QueryParam id: Int?): Box3490<List<Bean3490>> = |
| 54 | + Box3490(listOf(Bean3490(id?.toString() ?: "none"))) |
| 55 | +} |
| 56 | + |
| 57 | +data class Bean3490(val value: String) { |
| 58 | + override fun toString(): String { |
| 59 | + return value |
| 60 | + } |
| 61 | + |
| 62 | + companion object { |
| 63 | + @JvmStatic fun of(ctx: Context) = Bean3490(ctx.query("value").toString()) |
| 64 | + } |
| 65 | +} |
| 66 | + |
| 67 | +data class Box3490<T>(val value: T) |
0 commit comments