This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //call handler directly | |
| val request = Request(GET, "/any") | |
| val handlerResponse: Response = pingPongHandler(request) | |
| //call handler through routing | |
| val secondRequest = Request(GET, "/ping") | |
| .header("accept-encoding", "gzip") | |
| val routingCallResponse: Response = app(secondRequest) | |
| // or: start the HTTP server with the app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val pingPongHandler: HttpHandler = { _ -> Response(OK).body("pong!") } | |
| val greetHandler: HttpHandler = { req: Request -> | |
| val name: String? = req.query("name") | |
| Response(OK).body("hello ${name ?: "unknown!"}") | |
| } | |
| val routing: RoutingHttpHandler = routes( | |
| "/ping" bind GET to pingPongHandler, | |
| "/greet" bind GET to greetHandler | |
| ) | |
| val requestTimeLogger: Filter = Filter { next: HttpHandler -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val app: HttpHandler = { request: Request -> | |
| Response(OK).body(request.body) | |
| } | |
| val server = app.asServer(SunHttp(8000)).start() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public final class FunKt { | |
| public static final void loopWithRange() { | |
| IntProgression var10000 = RangesKt.step(RangesKt.downTo(5, 1), 2); | |
| int i = var10000.getFirst(); | |
| int var1 = var10000.getLast(); | |
| int var2 = var10000.getStep(); | |
| if (var2 >= 0) { | |
| if (i > var1) { | |
| return; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun loopWithRange(){ | |
| for(i in 5 downTo 1 step 2){ | |
| print(i) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public final class FileKt { | |
| public static final int myExtension(@NotNull MyClass $this$myExtension, @Nullable String value) { | |
| Intrinsics.checkNotNullParameter($this$myExtension, "$this$myExtension"); | |
| return value != null ? value.length() : 0; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public final class FileKt { | |
| public static final int myExtension(@NotNull MyClass $this$myExtension, @NotNull String value) { | |
| Intrinsics.checkNotNullParameter($this$myExtension, "$this$myExtension"); | |
| Intrinsics.checkNotNullParameter(value, "value"); | |
| return value.length(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public final class MyClass { | |
| private final int i; | |
| public final int getI() { | |
| return this.i; | |
| } | |
| public MyClass(int i) { | |
| this.i = i; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyClass(val i: Int) | |
| fun MyClass.myExtension(value: String) = value.length |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public final class FunKt { | |
| public static final void foobar() { | |
| } | |
| } |