Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinovega committed May 28, 2024
1 parent 01a235b commit f09ccf0
Showing 1 changed file with 6 additions and 33 deletions.
39 changes: 6 additions & 33 deletions daikoku/app/utils/errors.scala
Original file line number Diff line number Diff line change
@@ -1,40 +1,18 @@
package fr.maif.otoroshi.daikoku.utils

import diffson.PatchOps
import org.apache.pekko.http.scaladsl.util.FastFuture
import fr.maif.otoroshi.daikoku.env.Env
import fr.maif.otoroshi.daikoku.domain._
import fr.maif.otoroshi.daikoku.env.Env
import fr.maif.otoroshi.daikoku.login._
import fr.maif.otoroshi.daikoku.utils.RequestImplicits.EnhancedRequestHeader
import org.apache.pekko.http.scaladsl.util.FastFuture
import play.api.libs.json.Json
import play.api.mvc.Results.{Redirect, Status}
import play.api.mvc.{Request, RequestHeader, Result}
import play.api.mvc.{RequestHeader, Result}

import scala.concurrent.Future

object Errors {

val defaultTenant = Tenant(
id = Tenant.Default,
name = "Daikoky",
domain = "localhost",
defaultLanguage = Some("En"),
contact = "contact@foo.bar",
style = Some(
DaikokuStyle(
title = "Daikoku"
)
),
mailerSettings = Some(ConsoleMailerSettings()),
authProvider = AuthProvider.Local,
authProviderSettings = Json.obj(
"sessionMaxAge" -> 86400
),
bucketSettings = None,
otoroshiSettings = Set.empty,
adminApi = ApiId("no-api")
)

val messages = Map(
404 -> ("The page you're looking for does not exist", "notFound.gif")
)
Expand All @@ -50,9 +28,9 @@ object Errors {

val accept = req.headers.get("Accept").getOrElse("text/html").split(",").toSeq

if (accept.contains("text/html") && env.config.isDev) {
if (accept.contains("text/html")) {
FastFuture.successful(
Redirect(s"${req.theProtocol}://${tenant.domain}:${env.config.exposedPort}/")
Redirect(s"${req.theProtocol}://${tenant.domain}:${env.config.exposedPort}/error")
.withHeaders(
"x-error" -> "true",
"x-error-msg" -> message
Expand All @@ -62,12 +40,7 @@ object Errors {
// .getOrElse("--")
)
)
} else if (accept.contains("text/html") && env.config.isProd) {
assets.at("index.html")
.apply(req)
}

else {
} else {
FastFuture.successful(
status
.apply(Json.obj("error" -> message))
Expand Down

0 comments on commit f09ccf0

Please sign in to comment.