mirror of
https://github.com/ReVanced/revanced-api.git
synced 2026-01-26 12:41:04 +00:00
feat: Add OpenAPI docs and cache to routes
This commit is contained in:
@@ -1,7 +1,27 @@
|
||||
package app.revanced.api.configuration
|
||||
|
||||
import io.bkbn.kompendium.core.plugin.NotarizedRoute
|
||||
import io.ktor.http.*
|
||||
import io.ktor.http.content.*
|
||||
import io.ktor.server.application.*
|
||||
import io.ktor.server.plugins.cachingheaders.*
|
||||
import io.ktor.server.response.*
|
||||
import kotlin.time.Duration
|
||||
|
||||
suspend fun ApplicationCall.respondOrNotFound(value: Any?) = respond(value ?: HttpStatusCode.NotFound)
|
||||
internal suspend fun ApplicationCall.respondOrNotFound(value: Any?) = respond(value ?: HttpStatusCode.NotFound)
|
||||
|
||||
internal fun ApplicationCallPipeline.installCache(maxAge: Duration) =
|
||||
installCache(CacheControl.MaxAge(maxAgeSeconds = maxAge.inWholeSeconds.toInt()))
|
||||
|
||||
internal fun ApplicationCallPipeline.installNoCache() =
|
||||
installCache(CacheControl.NoCache(null))
|
||||
|
||||
internal fun ApplicationCallPipeline.installCache(cacheControl: CacheControl) =
|
||||
install(CachingHeaders) {
|
||||
options { _, _ ->
|
||||
CachingOptions(cacheControl)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun ApplicationCallPipeline.installNotarizedRoute(configure: NotarizedRoute.Config.() -> Unit = {}) =
|
||||
install(NotarizedRoute(), configure)
|
||||
|
||||
Reference in New Issue
Block a user