Skip to content

Commit

Permalink
Merge pull request #109 from Fabszn/fix_reload_filling_page
Browse files Browse the repository at this point in the history
fix reload filling page
  • Loading branch information
Fabszn authored Apr 13, 2023
2 parents 7276d89 + c65e7d8 commit 6b3da14
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions httpEngine/src/main/scala/org/floxx/env/api/StaticApi.scala
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
package org.floxx.env.api

import org.http4s.{HttpRoutes, Request, StaticFile}
import org.http4s.{ HttpRoutes, Request, StaticFile }
import org.http4s.dsl.Http4sDsl

import zio.interop.catz._


/**
* Helper to expose static files of app
*/
object StaticApi {

val dsl = Http4sDsl[ApiTask]
val dsl = Http4sDsl[ApiTask]

import dsl._

val excludePaths =Seq("infos", "favicon.ico")
val excludePaths = Seq("infos", "favicon.ico")

def api= HttpRoutes.of[ApiTask] {
case req @ GET -> Root => {
def api = HttpRoutes.of[ApiTask] {
case req @ GET -> Root => {
static("/assets/index.html", req)
}

Expand All @@ -29,12 +28,16 @@ object StaticApi {
static(s"/assets/${path}", req)
}

case req @ GET -> Root / path if path.nonEmpty && !excludePaths.contains(path) => {
case req @ GET -> Root / path1 if path1.nonEmpty && !excludePaths.contains(path1) =>
static("/assets/index.html", req)
}

}

case req @ GET -> Root / path1 / path2
if path1.nonEmpty && path2.nonEmpty && !excludePaths.contains(path1) && !excludePaths.contains(path2) =>
static("/assets/index.html", req)


}

def static(file: String, request: Request[ApiTask]) =
StaticFile.fromResource(file, Some(request)).getOrElseF {
Expand Down

0 comments on commit 6b3da14

Please sign in to comment.