RestFQL for ktor is a rest middleware that implements the specification.
In short RestFQL allows filtering of response driven by the querying side without breaking caching and keeping the capability for the backend to do optimizations as required.
- Add repository if not use the version on maven central
repositories {
...
maven {
url = uri("https://maven.pkg.github.com/restfql/ktor-restfql")
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")
}
}
}
- install with a package manager
val restfql_version = "1.0.0"
dependencies {
implementation("com.restfql:ktor-restfql:$restfql_version")
}
- Add the middleware to your ktor server
package com.restfql.ktor.example
import com.restfql.ktor.RestFQL
import io.ktor.server.application.*
import io.ktor.server.netty.*
import com.restfql.ktor.example.plugins.*
fun main(args: Array<String>) {
EngineMain.main(args)
}
fun Application.module() {
...
install(RestFQL)
}
- query passing the model as a query param call
fql