kottpd

Kottpd - REST framework written in pure Kotlin. It is avaliable from maven central repository. It supports plain HTTP and secured HTTPs.

    <dependency>
        <groupId>com.github.gimlet2</groupId>
        <artifactId>kottpd</artifactId>
        <version>0.1.3</version>
    </dependency>
    val server = Server() // default port is 9000
    server.staticFiles("/public") // specify path to static content folder
    server.get("/hello", { req, res -> res.send("Hello") }) // use res.send to send data to response explicitly
    server.get("/hello_simple", { req, res -> "Hello" }) // or just return some value and that will be sent to response automatically
    server.get("/do/.*/smth", { req, res -> res.send("Hello world") }) // also you could bind handlers by regular expressions
    server.post("/data", { req, res -> res.send(req.content, Status.Created) }) // send method accepts status
    // Filters
    server.before("/hello", { req, res -> res.send("before\n") })
    server.before({ req, res -> res.send("ALL before\n") })
    server.after("/hello", { req, res -> res.send("\nafter\n") })
    server.after({ req, res -> res.send("ALL after\n") })
    // exceptions handler
    server.exception(IllegalStateException::class, { req, res -> "Illegal State" })
    server.start(9443, true, "./keystore.jks", "password") // for secured conection
    server.start()
compile "com.github.gimlet2:kottpd:0.1.3"

Related Libraries

tekniq

A framework designed around Kotlin providing a full-featured HTTP Framework, Restful HTTP Client, JDBC DSL, Loading Cache, Configurations, Validations, and more

Last updated 3 mins ago

spark-kotlin

A Spark DSL in idiomatic kotlin // dependency - com.sparkjava -spark-kotlin -1.0.0-alpha

Last updated 3 mins ago

kog

🌶 A simple Kotlin web framework inspired by Clojure's Ring.

Last updated 3 mins ago

fuel

The easiest HTTP networking library for Kotlin/Android

Last updated 3 mins ago

khttp

Kotlin HTTP requests library. Similar to Python requests.

Last updated 3 mins ago