Skip to content

Instantly share code, notes, and snippets.

View s1monw1's full-sized avatar
☁️
Hello, cloud.

Simon Wirtz s1monw1

☁️
Hello, cloud.
View GitHub Profile
//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
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 ->
val app: HttpHandler = { request: Request ->
Response(OK).body(request.body)
}
val server = app.asServer(SunHttp(8000)).start()
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;
}
fun loopWithRange(){
for(i in 5 downTo 1 step 2){
print(i)
}
}
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;
}
}
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();
}
}
public final class MyClass {
private final int i;
public final int getI() {
return this.i;
}
public MyClass(int i) {
this.i = i;
}
class MyClass(val i: Int)
fun MyClass.myExtension(value: String) = value.length
public final class FunKt {
public static final void foobar() {
}
}