mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-05 22:55:58 +00:00
Add redirect for root (/
) to gui (/app
)
This commit is contained in:
parent
1c13537f47
commit
8f7e8c7800
@ -1,11 +1,13 @@
|
|||||||
package docspell.restserver
|
package docspell.restserver
|
||||||
|
|
||||||
import cats.effect._
|
import cats.effect._
|
||||||
|
import cats.data.{Kleisli, OptionT}
|
||||||
import docspell.backend.auth.AuthToken
|
import docspell.backend.auth.AuthToken
|
||||||
import docspell.restserver.routes._
|
import docspell.restserver.routes._
|
||||||
import docspell.restserver.webapp._
|
import docspell.restserver.webapp._
|
||||||
import fs2.Stream
|
import fs2.Stream
|
||||||
import org.http4s.HttpRoutes
|
import org.http4s._
|
||||||
|
import org.http4s.headers.Location
|
||||||
import org.http4s.implicits._
|
import org.http4s.implicits._
|
||||||
import org.http4s.server.Router
|
import org.http4s.server.Router
|
||||||
import org.http4s.server.blaze.BlazeServerBuilder
|
import org.http4s.server.blaze.BlazeServerBuilder
|
||||||
@ -33,7 +35,8 @@ object RestServer {
|
|||||||
},
|
},
|
||||||
"/api/doc" -> templates.doc,
|
"/api/doc" -> templates.doc,
|
||||||
"/app/assets" -> WebjarRoutes.appRoutes[F](blocker),
|
"/app/assets" -> WebjarRoutes.appRoutes[F](blocker),
|
||||||
"/app" -> templates.app
|
"/app" -> templates.app,
|
||||||
|
"/" -> redirectTo("/app")
|
||||||
).orNotFound
|
).orNotFound
|
||||||
|
|
||||||
finalHttpApp = Logger.httpApp(logHeaders = false, logBody = false)(httpApp)
|
finalHttpApp = Logger.httpApp(logHeaders = false, logBody = false)(httpApp)
|
||||||
@ -82,4 +85,15 @@ object RestServer {
|
|||||||
"upload" -> UploadRoutes.open(restApp.backend, cfg),
|
"upload" -> UploadRoutes.open(restApp.backend, cfg),
|
||||||
"checkfile" -> CheckFileRoutes.open(restApp.backend)
|
"checkfile" -> CheckFileRoutes.open(restApp.backend)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def redirectTo[F[_]: Effect](path: String): HttpRoutes[F] =
|
||||||
|
Kleisli(_ =>
|
||||||
|
OptionT.pure(
|
||||||
|
Response[F](
|
||||||
|
Status.SeeOther,
|
||||||
|
body = Stream.empty,
|
||||||
|
headers = Headers.of(Location(Uri(path = path)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user