https://github.com/ollls/hello-http
https://github.com/ollls/hello-http
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/ollls/hello-http
- Owner: ollls
- Created: 2021-03-11T18:34:44.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-06-20T21:39:53.000Z (about 3 years ago)
- Last Synced: 2025-04-09T23:51:21.585Z (over 1 year ago)
- Language: Scala
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# hello-http
to run: sbt run
Server code:
https://github.com/ollls/hello-http/blob/main/src/main/scala/example/Hello.scala
Shorter example:
```scala
package example
import zio.logging.backend.SLF4J
import zio.{ZIO, Chunk}
import zhttp.Method._
import zhttp.dsl._
import zhttp.{TLSServer, TcpServer, HttpRoutes}
import zhttp.{MultiPart, Headers, ContentType, Response, FileUtils}
object MyApp extends zio.ZIOAppDefault {
override val bootstrap =
zio.Runtime.removeDefaultLoggers ++ SLF4J.slf4j ++ zio.Runtime.enableWorkStealing
val r = HttpRoutes.of { case GET -> Root / "health" =>
ZIO.attempt(Response.Ok().asTextBody("Health Check Ok"))
}
val myHttp =
new TcpServer[Any](port = 8080, keepAlive = 2000, serverIP = "0.0.0.0")
val run = myHttp.run(r)
}
```
To enable more detailed logging, use logback-test.xml with "debug" or "trace" levels
```xml
```