mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-04 10:29:34 +00:00
Fix redirecting /
to /app
Before all paths not otherwise handled were redirected, but it should only be the root path.
This commit is contained in:
parent
89fd91894d
commit
229baa0719
@ -17,6 +17,7 @@
|
||||
from an item detail to the front-page, the search menu remembers the
|
||||
last state, but dates were cleared.
|
||||
- More fixes regarding character encodings when reading e-mails.
|
||||
- Fix redirecting `/` to `/app`.
|
||||
|
||||
### Configuration Changes
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package docspell.restserver
|
||||
|
||||
import cats.effect._
|
||||
import cats.data.{Kleisli, OptionT}
|
||||
import cats.implicits._
|
||||
import docspell.common.Pools
|
||||
import docspell.backend.auth.AuthToken
|
||||
import docspell.restserver.routes._
|
||||
@ -13,6 +13,7 @@ import org.http4s.implicits._
|
||||
import org.http4s.server.Router
|
||||
import org.http4s.server.blaze.BlazeServerBuilder
|
||||
import org.http4s.server.middleware.Logger
|
||||
import org.http4s.dsl.Http4sDsl
|
||||
|
||||
object RestServer {
|
||||
|
||||
@ -88,14 +89,17 @@ object RestServer {
|
||||
"checkfile" -> CheckFileRoutes.open(restApp.backend)
|
||||
)
|
||||
|
||||
def redirectTo[F[_]: Effect](path: String): HttpRoutes[F] =
|
||||
Kleisli(_ =>
|
||||
OptionT.pure(
|
||||
def redirectTo[F[_]: Effect](path: String): HttpRoutes[F] = {
|
||||
val dsl = new Http4sDsl[F] {}
|
||||
import dsl._
|
||||
|
||||
HttpRoutes.of {
|
||||
case GET -> Root =>
|
||||
Response[F](
|
||||
Status.SeeOther,
|
||||
body = Stream.empty,
|
||||
headers = Headers.of(Location(Uri(path = path)))
|
||||
)
|
||||
)
|
||||
)
|
||||
).pure[F]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user