diff options
author | Julio Capote <jcapote@gmail.com> | 2023-01-24 03:20:47 +0000 |
---|---|---|
committer | Julio Capote <jcapote@gmail.com> | 2023-01-24 03:20:47 +0000 |
commit | f24f2d15275961f1c0144e68fde75a60aeaaa165 (patch) | |
tree | 38be1626f3ade436fbd17eadb2753fa2f0effb37 /content/blog/2012-11-07-announcing-finatra-1-0-0.markdown | |
parent | bf04383b34c4a4fdfe239de2805a30a051921002 (diff) | |
download | capotej.com-f24f2d15275961f1c0144e68fde75a60aeaaa165.tar.gz |
move to bear theme
Diffstat (limited to 'content/blog/2012-11-07-announcing-finatra-1-0-0.markdown')
-rw-r--r-- | content/blog/2012-11-07-announcing-finatra-1-0-0.markdown | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/content/blog/2012-11-07-announcing-finatra-1-0-0.markdown b/content/blog/2012-11-07-announcing-finatra-1-0-0.markdown new file mode 100644 index 0000000..296cd45 --- /dev/null +++ b/content/blog/2012-11-07-announcing-finatra-1-0-0.markdown @@ -0,0 +1,73 @@ +--- +title: "Announcing Finatra 1.0.0" +date: 2012-11-07T21:20:00Z +comments: true +tags: ["finatra", "scala"] +--- + +After months of work [Finatra](https://github.com/capotej/finatra#readme) 1.0.0 is finally available! Finatra is a scala web framework inspired by [Sinatra](https://github.com/sinatra/sinatra#readme) built on top of [Finagle](http://twitter.github.com/finagle). + +<!--more--> + +### The API + +The API looks like what you'd expect, here's a simple endpoint that uses route parameters: + +```scala +get("/user/:username") { request => + val username = request.routeParams.getOrElse("username", "default_user") + render.plain("hello " + username).toFuture +} +``` + +The ```toFuture``` call means that the response is actually a [Future](http://twitter.github.com/scala_school/finagle.html#Future), a powerful concurrency abstraction worth checking out. + +Testing it is just as easy: + +```scala +"GET /user/foo" should "responsd with hello foo" in { + get("/user/foo") + response.body should equal ("hello foo") +} +``` + +### A super quick demo + +```sh +$ git clone https://github.com/capotej/finatra.git +$ cd finatra +$ ./finatra new com.example.myapp /tmp +``` + +Now you have an ```/tmp/myapp``` you can use: + +```sh + +$ cd /tmp/myapp +$ mvn scala:run +``` + +A simple app should've started up locally on port 7070, verify with: + +```sh +$ curl http://locahost:7070 +hello world +``` + +You can see the rest of the endpoints at ```/tmp/myapp/src/main/scala/com/example/myapp/App.scala``` + +### Heroku integration + +The generated apps work in heroku out of the box: + +```sh +$ heroku create +$ git init +$ git add . +$ git commit -am 'stuff' +$ git push heroku master +``` + +Make sure to see the full details in the [README](https://github.com/capotej/finatra#readme) and check out the [example app](https://github.com/capotej/finatra-example). + +Props to [@twoism](http://twitter.com/twoism) and [@thisisfranklin](http://twitter.com/thisisfranklin) for their code, feedback and moral support. |