Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Backend Engineering for Android Developers

Backend Engineering for Android Developers

With Kotlin growing in popularity, it's about time we start looking at Kotlin as a language that has superpowers.
When we talk about backend technologies, we have a lot of languages/frameworks like Go, Java, Python, etc.
But when we talk about Kotlin as a backend language, it might raise a lot of eyebrows
But let me try to convince you that Kotlin is definitely a good choice for Backend! We will talk about Ktor (A framework for Kotlin) to build a fast backend that can be re-used on your client-side

Himanshu Singh

October 22, 2021
Tweet

More Decks by Himanshu Singh

Other Decks in Technology

Transcript

  1. 4 Agenda: Backend for Android Engineers 01. Intro Kotlin Android?

    Backend Benefits 02. Kotlin Frameworks Ktor Spring Boot Vertx. Etc. 03. Ktor Why? How? Benefits 04. Tutorial Setting up Restful APIs Routing HTTP Verbs Features Location Status Pages 05. Why to use as Android Developer?
  2. Benefits 1. 2. 3. 4. 5. Expressive Tooling Migration 6.

    Scalable! Community Support Ease of Learning
  3. Ktor 1. 2. 3. 4. 5. Light weighted Backed by

    Jetbrains Coroutine support Open sourced Scalable -> ∞
  4. 22  fun main() { embeddedServer(Netty, port = 8080, host

    = "0.0.0.0") { configureRouting() }.start(wait = true) }
  5. 23  fun main() { embeddedServer(Netty, port = 8080, host

    = "0.0.0.0") { configureRouting() }.start(wait = true) }
  6. 24  fun main() { embeddedServer(Netty, port = 8080, host

    = "0.0.0.0") { configureRouting() }.start(wait = true) }
  7. 26  fun Application.configureRouting() { // Starting point for a

    Ktor app: routing { get("/") { call.respondText("Hello World!") } } }
  8. 27  fun Application.configureRouting() { // Starting point for a

    Ktor app: routing { get("/") { call.respondText("Hello World!") } } }
  9. 28  fun Application.configureRouting() { // Starting point for a

    Ktor app: routing { get("/") { call.respondText("Hello World!") } } }
  10. 29  fun Application.configureRouting() { // Starting point for a

    Ktor app: routing { get("/") { call.respondText("Hello World!") } } }
  11. 30  fun Application.configureRouting() { // Starting point for a

    Ktor app: routing { get("/") { call.respondText("Hello World!") } } }
  12. 33  routing { get("/") { //code } post("/") {

    //code } delete("/") { //code } put("/") { //code } }
  13. 37  fun main() { embeddedServer(Netty, port = 8080, host

    = "0.0.0.0") { configureRouting() dummyPlugin() }.start(wait = true) }
  14. 42  { "name":"Himanshu", "age":26, "job":"Clue" } data class User(

    val name:String, val age:Int, val job:String )
  15. “ A mechanism to create routes in a typed way,

    for both: constructing URLs and reading the parameters.
  16. 54  install(StatusPages) { exception<AuthenticationException> { cause -> call.respond(HttpStatusCode.Unauthorized) }

    exception<AuthorizationException> { cause -> call.respond(HttpStatusCode.Forbidden) } }
  17. Why? 1. 2. 3. 4. 5. KMongo/Expose In build Authentication/Auth

    Velocity / Kotlin HTML Gson/Jackson Swagger, ORM etc.
  18. Why? 1. 2. 3. 4. 5. Uses our fav. Kotlin

    KMM support Easy learning curve. Supports JVM Libraries Makes you a full stack developer.