Permalink
Browse files

Fix the example generation.

  • Loading branch information...
guillaumebort committed Nov 10, 2017
1 parent d29d4dc commit 39f983e20b26e0c8872c937bfee09519d4e8a8d7
Showing with 8 additions and 7 deletions.
  1. +1 −1 README.md
  2. +2 −2 build.sbt
  3. +4 −3 examples/src/main/scala/DatabaseAccess.scala
  4. +1 −1 examples/src/main/scala/Http2Server.scala
View
@@ -6,7 +6,7 @@ An HTTP & HTTP/2 Server and Client library for Scala.
## About the library
A server is built from a plain function accepting an HTTP request and eventually giving back an HTTP response. The computation is wrapped into an [effect](https://github.com/typelevel/cats-effect) and can handle pure & impure and synchronous & asynchronous scenarios. Requests and responses are just HTTP metadata along with a lazy content body based on [fs2](https://github.com/functional-streams-for-scala/fs2), making it easy to handle streaming scenarios if needed. For additional convenience, the library provides content encoders and decoders for the common scala types. Clients and Servers share the same API and the same concepts, making it easy to compose them. SSL is supported on both sides. HTTP/2 too 🎷.
A server is built from a plain function accepting an HTTP request and eventually giving back an HTTP response. The computation is wrapped into an [effect](https://github.com/typelevel/cats-effect) and can handle pure & impure and synchronous & asynchronous scenarios. Requests and responses are just HTTP metadata along with a lazy content body based on [fs2](https://github.com/functional-streams-for-scala/fs2), making it easy to handle streaming scenarios if needed. For additional convenience, the library provides content encoders and decoders for the common scala types. Clients and Servers share the same API and the same concepts, making it easy to compose them. __SSL__ is supported on both sides. __HTTP/2__ too ✌️.
## Hello World
View
@@ -189,8 +189,8 @@ lazy val examples: Project =
"-P:socco:package_lol.http:https://criteo.github.io/lolhttp/api/",
"-P:socco:package_scala.concurrent:http://www.scala-lang.org/api/current/",
"-P:socco:package_io.circe:http://circe.github.io/circe/api/",
"-P:socco:package_doobie:https://www.javadoc.io/doc/org.tpolecat/doobie-core_2.12/0.5.0-M8",
"-P:socco:package_cats.effect:https://oss.sonatype.org/service/local/repositories/releases/archive/org/typelevel/cats-effect_2.12/0.4/cats-effect_2.12-0.4-javadoc.jar/!/",
"-P:socco:package_doobie:https://static.javadoc.io/org.tpolecat/doobie-core_2.12/0.5.0-M8",
"-P:socco:package_cats.effect:https://oss.sonatype.org/service/local/repositories/releases/archive/org/typelevel/cats-effect_2.12/0.4/cats-effect_2.12-0.4-javadoc.jar/!",
"-P:socco:package_fs2:https://oss.sonatype.org/service/local/repositories/releases/archive/co/fs2/fs2-core_2.12/0.9.4/fs2-core_2.12-0.9.4-javadoc.jar/!/"
)
)).getOrElse(Nil): _*
@@ -9,6 +9,7 @@ import lol.html._
// We will configure doobie to use the cats `IO` effect,
// so it will play well with lolhttp 🎉.
import cats.effect.{ IO }
import cats.implicits._
// Now we just import the needed package for doobie.
import doobie.h2._
@@ -26,22 +27,22 @@ object DatabaseAccess {
code character(3) NOT NULL,
name text NOT NULL
);
"""
""".update
// Also we need to import fake data for the example.
val importData = sql"""
INSERT INTO country (code, name) VALUES
('FR', 'France'),
('US', 'United States'),
('DE', 'GERMANY');
"""
""".update
// This is our setup script. Connect to the database, create the schema
// and import the data.
val setup = for {
xa <- H2Transactor[IO]("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", "sa", "")
_ <- xa.setMaxConnections(10)
_ <- (createTable ++ importData).update.run.transact(xa)
_ <- (createTable.run *> importData.run).transact(xa)
} yield (xa)
// We run our setup script to startup the database and we keep a
@@ -25,7 +25,7 @@ object Http2Server {
)
// By specifying the `protocols` options we allow this server to handle both HTTP/1.1 & HTTP/2.
Server.listen(8443, ssl = Some(ssl), options = ServerOptions(protocols = Set(HTTP, HTTP2), debug = None)) {
Server.listen(8443, ssl = Some(ssl), options = ServerOptions(protocols = Set(HTTP, HTTP2))) {
// The home page display the current protocol using `req.protocol`.
case req @ url"/" =>

0 comments on commit 39f983e

Please sign in to comment.