diff --git a/testcases/src/main/scala/main.scala b/testcases/src/main/scala/main.scala index 3d5d139..3c1df0e 100644 --- a/testcases/src/main/scala/main.scala +++ b/testcases/src/main/scala/main.scala @@ -1,5 +1,7 @@ package guinep.compiletest +import com.softwaremill.quicklens.* + def upperCaseText(text: String): String = text.toUpperCase @@ -134,6 +136,7 @@ def printsWeirdGADT1(g: WeirdGADT1[Int]): String = g match @main def run: Unit = guinep.web + .withModifyConfig(_.modify(_.httpServerConfig).using(_.port(6969))) .apply( upperCaseText, add, diff --git a/web/src/main/scala/api.scala b/web/src/main/scala/api.scala index 6bad335..a9c4dad 100644 --- a/web/src/main/scala/api.scala +++ b/web/src/main/scala/api.scala @@ -23,7 +23,8 @@ def web: GuinepWeb = * @param requireNonNullableInputs when set, all non-nullable types will correspond to required inputs in the frontend */ case class GuinepWebConfig( - requireNonNullableInputs: Boolean = false + requireNonNullableInputs: Boolean = false, + httpServerConfig: zio.http.Server.Config = zio.http.Server.Config.default.port(8090) ) object GuinepWebConfig: @@ -56,7 +57,8 @@ private case class GuinepWeb(config: GuinepWebConfig = GuinepWebConfig.default) s"""|Duplicate function names found: ${functionsInfosMap.filter(_._2.size > 1).keys.mkString(", ")} |Ignoring duplicates""".stripMargin ) - println("Starting GUInep web server at http://localhost:8090/") + val prettyAddress = config.httpServerConfig.address.getAddress().getHostAddress().toString() + ":" + config.httpServerConfig.address.getPort() + println(s"Starting GUInep web server at $prettyAddress") webgen.genWeb( funs = functionsInfos.distinct.map(fun => fun.name -> fun), config = config diff --git a/web/src/main/scala/webgen.scala b/web/src/main/scala/webgen.scala index 1a93a7d..3a2b822 100644 --- a/web/src/main/scala/webgen.scala +++ b/web/src/main/scala/webgen.scala @@ -53,6 +53,11 @@ private[guinep] object webgen { ).sandbox.toHttpApp def run = - Server.serve(app).provide(Server.defaultWithPort(8090)) + Server + .serve(app) + .provide( + ZLayer.succeed(config.httpServerConfig), + Server.live + ) } }