Skip to content

Commit

Permalink
Add http4s (#359)
Browse files Browse the repository at this point in the history
* Added scala/http4s. Closes #336

* minor

* add http4s on framework list
  • Loading branch information
mfirry authored and waghanza committed Sep 9, 2018
1 parent e1cb884 commit 3264e7e
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 0 deletions.
6 changes: 6 additions & 0 deletions neph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ cpp:
scala:
dependencies:
- akkahttp
- http4s

csharp:
dependencies:
Expand Down Expand Up @@ -344,6 +345,11 @@ akkahttp:
- docker build -t akkahttp .
directory: scala/akkahttp

http4s:
commands:
- docker build -t http4s .
directory: scala/http4s

aspnetcore:
commands:
- docker build -t aspnetcore .
Expand Down
4 changes: 4 additions & 0 deletions scala/http4s/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target/
project/project
project/target
*.class
13 changes: 13 additions & 0 deletions scala/http4s/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM bigtruedata/sbt

WORKDIR /usr/src/app

COPY build.sbt ./
COPY src src
COPY project project

RUN sbt assembly

EXPOSE 3000

CMD java -jar target/scala-2.12/*assembly*.jar
15 changes: 15 additions & 0 deletions scala/http4s/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
val Http4sVersion = "0.18.17"

lazy val root = (project in file("."))
.settings(
organization := "the.benchmarker",
name := "http4s",
version := "0.0.1-SNAPSHOT",
scalaVersion := "2.12.6",
libraryDependencies ++= Seq(
"org.http4s" %% "http4s-blaze-server" % Http4sVersion,
"org.http4s" %% "http4s-circe" % Http4sVersion,
"org.http4s" %% "http4s-dsl" % Http4sVersion
)
)

1 change: 1 addition & 0 deletions scala/http4s/project/assembly.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.4")
2 changes: 2 additions & 0 deletions scala/http4s/project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sbt.version=0.13.15

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package the.benchmarker.http4s

import cats.effect.{Effect, IO}
import fs2.StreamApp
import org.http4s.server.blaze.BlazeBuilder

import scala.concurrent.ExecutionContext

object HelloWorldServer extends StreamApp[IO] {
import scala.concurrent.ExecutionContext.Implicits.global

def stream(args: List[String], requestShutdown: IO[Unit]) = ServerStream.stream[IO]
}

object ServerStream {

def helloWorldService[F[_]: Effect] = new HelloWorldService[F].service

def stream[F[_]: Effect](implicit ec: ExecutionContext) =
BlazeBuilder[F]
.bindHttp(3000, "0.0.0.0")
.mountService(helloWorldService, "/")
.serve
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package the.benchmarker.http4s

import cats.effect.Effect
import io.circe.Json
import org.http4s.HttpService
import org.http4s.dsl.Http4sDsl

class HelloWorldService[F[_]: Effect] extends Http4sDsl[F] {

val service: HttpService[F] = {
HttpService[F] {
case GET -> Root =>
Ok("")
case POST -> Root / "user" =>
Ok("")
case GET -> Root / "user" / name =>
Ok(name)
}
}
}
1 change: 1 addition & 0 deletions tools/src/benchmarker.cr
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ LANGS = [
]},
{lang: "scala", targets: [
{name: "akkahttp", repo: "akka/akka-http"},
{name: "http4s", repo: "http4s/http4s"},
]},
{lang: "csharp", targets: [
{name: "aspnetcore", repo: "aspnet/Home"},
Expand Down

0 comments on commit 3264e7e

Please sign in to comment.