Created
October 16, 2024 19:46
-
-
Save elyphas/1c2695576626423effcc67334caed2e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//package manik1.manik1 | |
import cats.implicits._ | |
import cats.effect.{IO, IOApp} | |
import org.http4s._ | |
import org.http4s.ember.server.EmberServerBuilder | |
import org.http4s.implicits._ | |
import org.http4s.server.middleware.{ErrorAction, ErrorHandling} | |
import com.comcast.ip4s.{Host, IpLiteralSyntax, Port} | |
import org.http4s.server.Router | |
//import org.http4s.circe.CirceEntityDecoder._ | |
//import io.circe.Encoder | |
//import io.circe.literal._ | |
//import org.http4s.circe._ | |
//import io.circe.syntax._ | |
//import io.circe.generic.auto._ | |
//import scala.concurrent.Future | |
//import shared.mytypes.QryPedidoGralData | |
import scala.concurrent.duration._ | |
object Main extends IOApp.Simple { | |
import org.http4s.ember.client.EmberClientBuilder | |
import cats.effect.unsafe.implicits.global | |
import server_routes._ | |
//GetLstItemsRoute.route <+> | |
//FTSArticulo2Routes.route <+> | |
//FTSOficinaRoutes.route <+> | |
//FtsPartidaRoutes.route <+> | |
val allRoutes = StaticFilesRoutes.route | |
/**<+> | |
EventRowRoute.route <+> | |
GetNextClaveRoute.route <+> | |
CatalogArticuloRoute.route <+> | |
GetItemsFromCatalogRoute.route <+> | |
LogginRoute.route <+> | |
GralDataProcessRoute.route <+> | |
QryPedidoGralDataRoute.route <+> | |
QryDetallePedidoRoute.route <+> | |
CatalogProveedorRoute.route <+> | |
GetComparativeRoute.route <+> | |
GetTenderersRoute.route <+> | |
GetQuotationRoute.route <+> | |
FtsRoute.route <+> | |
GetFilesRoute.route*/ | |
val app = Router( | |
"/" -> allRoutes | |
).orNotFound | |
val appWithErrorLogging = ErrorHandling.Recover.total( | |
ErrorAction.log( | |
app, | |
messageFailureLogAction = (t, msg) => IO.println(msg) >> IO.println(t), | |
serviceErrorLogAction = (t, msg) => IO.println(msg) >> IO.println(t) | |
) | |
) | |
val runServer: IO[Unit] = | |
EmberServerBuilder | |
.default[IO] | |
.withPort(port"8091") | |
.withHost(host"127.0.0.1") // Usually people use 0.0.0.0 to bind to any public IP address of your machine. | |
.withHttpApp(appWithErrorLogging) | |
.withShutdownTimeout(1.second) | |
.build | |
.evalTap { server => | |
IO.println(s"Server started at ${server.address}") | |
}.useForever | |
override final val run: IO[Unit] = runServer | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment