Giter Club home page Giter Club logo

kottpd's Introduction

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.1</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()

kottpd's People

Contributors

gimlet2 avatar

Watchers

Kamil Shersheyev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.