Skip to content

Commit

Permalink
use request.absoluteURI() as fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
zingmane committed Mar 13, 2024
1 parent 3a8727d commit 9054c69
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/scala/com/campudus/tableaux/Starter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Starter extends ScalaVerticle with LazyLogging {
val uploadsDirectory = getStringDefault(config, "uploadsDirectory", Starter.DEFAULT_UPLOADS_DIRECTORY)
val authConfig = config.getJsonObject("auth", Json.obj())
val rolePermissionsPath = getStringDefault(config, "rolePermissionsPath", Starter.DEFAULT_ROLE_PERMISSIONS_PATH)
val openApiUrl = getStringDefault(config, "openApiUrl", "")
val openApiUrl = Option(getStringDefault(config, "openApiUrl", null))

val rolePermissions = FileUtils(vertxAccessContainer()).readJsonFile(rolePermissionsPath, Json.emptyObj())

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/com/campudus/tableaux/TableauxConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TableauxConfig(
workingDirectory: String,
uploadsDirectory: String,
val rolePermissions: JsonObject,
val openApiUrl: String = ""
val openApiUrl: Option[String] = None
) extends VertxAccess {

def uploadsDirectoryPath(): Path = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,12 @@ class DocumentationRouter(override val config: TableauxConfig) extends BaseRoute
})

val forwardedUrl = request.getHeader("x-forwarded-url")
val openApiUrl = config.openApiUrl

val uri = (forwardedScheme, forwardedHost, forwardedUrl) match {
case (Some(scheme), Some(host), Some(query)) => s"$scheme://$host$query"
case _ => config.openApiUrl
val uri = (forwardedScheme, forwardedHost, forwardedUrl, openApiUrl) match {
case (Some(scheme), Some(host), Some(query), _) => s"$scheme://$host$query"
case (_, _, _, Some(openApiUrl)) => openApiUrl
case _ => request.absoluteURI()
}

DocUriParser.parse(uri)
Expand Down

0 comments on commit 9054c69

Please sign in to comment.