Beginning of a backend journey
Introduction is in order because this post is the first of many to come. I’ve been trying to get myself started with backend development. Main reason is that I love learning new stuff, second is that I am an android developer and some of my new project ideas require some backend code(performance or security reasons). So, I’ve been doing some backend development now and then. But the problem is I take relatively big breaks, and the time I return to the project I need some documentation to remember some of the concepts. Hopefully this series will provide that :)
Remember, most of my decisions will be opinionated and just me experimenting some of the concepts that are new to me. So, be kind when giving feedback :)
I am already going to learn a lot of new concepts and learning a new language along the way will makes things more difficult, which eventually will deter me away from the project. It only make sense for me to choose Kotlin and Ktor framework to begin my journey.
Ktor Project generator is a great tool to kickstart a project. You can configure the project, dependencies and some of the features. It generates ready-to-use project templates with proper setup and configurations.
https://start.ktor.io/settings
I have used this tool before, but adding a lot of the features at first will defeat my purpose. I’ll just create an empty project.
Download it.
Open it with IntelliJ IDE.
Init git and push it to a remote repository.
Run the project, click the link in the build window, and there is nothing.
Project comes with routing configuration in Application.kt (this may be different from yours if you selected some features in project generator)
fun Application.module() {
configureRouting()
}
but the function block is empty
fun Application.configureRouting() {
}
I am going to add routing for root directory
fun Application.configureRouting() {
routing {
get("/") {
call.respondText("{\"message\":\"Hello World!\"}")
}
}
}
result is;
🥳 yaay the first response of the api
This may not seem like a lot of progress but I will keep it short for this one as introduction. I may take up the pace in the next posts, but try not to bloat up individual posts with various of concepts. I will keep it simple and frequent.
See you in the next posts…