-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from navikt/metrics
Metrics
- Loading branch information
Showing
41 changed files
with
873 additions
and
690 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 55 additions & 19 deletions
74
src/main/kotlin/no/nav/meldeplikt/meldekortservice/api/Internal.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,83 @@ | ||
package no.nav.meldeplikt.meldekortservice.api | ||
|
||
import io.ktor.application.* | ||
import io.ktor.http.* | ||
import io.ktor.response.* | ||
import io.ktor.routing.* | ||
import io.ktor.server.application.* | ||
import io.ktor.server.locations.* | ||
import io.ktor.server.response.* | ||
import io.ktor.server.routing.* | ||
import io.micrometer.prometheus.PrometheusMeterRegistry | ||
import no.nav.meldeplikt.meldekortservice.config.SWAGGER_URL_V1 | ||
import no.nav.meldeplikt.meldekortservice.config.swagger | ||
import no.nav.meldeplikt.meldekortservice.utils.API_PATH | ||
import no.nav.meldeplikt.meldekortservice.utils.BASE_PATH | ||
import no.nav.meldeplikt.meldekortservice.utils.INTERNAL_PATH | ||
import no.nav.meldeplikt.meldekortservice.utils.swagger.SwaggerUi | ||
|
||
fun Route.healthApi() { | ||
@KtorExperimentalLocationsAPI | ||
fun Route.healthApi(appMicrometerRegistry: PrometheusMeterRegistry) { | ||
|
||
route(INTERNAL_PATH) { | ||
val swaggerUI = SwaggerUi() | ||
|
||
get("") { | ||
call.respondRedirect(SWAGGER_URL_V1) | ||
} | ||
|
||
get("/") { | ||
call.respondRedirect(SWAGGER_URL_V1) | ||
} | ||
|
||
get("/apidocs") { | ||
call.respondRedirect(SWAGGER_URL_V1) | ||
} | ||
|
||
get("/apidocs/") { | ||
call.respondRedirect(SWAGGER_URL_V1) | ||
} | ||
|
||
get("/apidocs/{fileName}") { | ||
val fileName = call.parameters["fileName"] | ||
if (fileName == "swagger.json") { | ||
call.respond(swagger) | ||
} else { | ||
swaggerUI.serve(fileName, call) | ||
} | ||
} | ||
|
||
get("/isAlive") { | ||
call.respondText(text = "Alive", contentType = ContentType.Text.Plain) | ||
call.respondText("Alive") | ||
} | ||
|
||
get("/isReady") { | ||
call.respondText(text = "Ready", contentType = ContentType.Text.Plain) | ||
call.respondText("Ready") | ||
} | ||
|
||
get("/ping") { | ||
val pingJsonResponse = """{"ping": "pong"}""" | ||
call.respondText(text = pingJsonResponse, contentType = ContentType.Application.Json) | ||
} | ||
|
||
get("/metrics") { | ||
call.respondText(appMicrometerRegistry.scrape()) | ||
} | ||
} | ||
} | ||
|
||
fun Routing.swaggerRoutes() { | ||
val swaggerUI = SwaggerUi() | ||
|
||
get(BASE_PATH) { call.respondRedirect(SWAGGER_URL_V1) } | ||
get(API_PATH) { call.respondRedirect(SWAGGER_URL_V1) } | ||
get("$INTERNAL_PATH/apidocs") { call.respondRedirect(SWAGGER_URL_V1) } | ||
get("$INTERNAL_PATH/apidocs/{fileName}") { | ||
val fileName = call.parameters["fileName"] | ||
if (fileName == "swagger.json") { | ||
call.respond(swagger) | ||
} else { | ||
swaggerUI.serve(fileName, call) | ||
route(BASE_PATH) { | ||
get("") { | ||
call.respondRedirect(SWAGGER_URL_V1) | ||
} | ||
|
||
get("/") { | ||
call.respondRedirect(SWAGGER_URL_V1) | ||
} | ||
|
||
get("/api") { | ||
call.respondRedirect(SWAGGER_URL_V1) | ||
} | ||
|
||
get("/api/") { | ||
call.respondRedirect(SWAGGER_URL_V1) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.