Skip to content

yennanliu/FinatraHelloWorld

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FinatraHelloWorld

  • Build REST API via Scala via Finatra framework
  • Finatra is an API framework build based on TwitterServer

Quick start

Quick start

Basics

sbt assembly
java -cp target/scala-2.11/finatrahelloworld_2.11-1.0.jar com.twitter.server.FitmanAppGet
# test API
curl http://localhost:8080/wazzup
sbt assembly
java -cp target/scala-2.11/finatrahelloworld_2.11-1.0.jar com.twitter.server.FitmanAppPost
# test API
curl -X POST -H "Content-Type: application/json" \
    -d '{ "id": 999, "name": "JACK"}' \
   localhost:8080/hi
# response
# ----> Hello JACK with id 999
sbt assembly
java -cp target/scala-2.11/finatrahelloworld_2.11-1.0.jar com.twitter.server.FitmanAppRedirect
# test API
curl http://localhost:8080/foo

Json Patch API (dev) : FitmanAppJSONPatchRequests.scala

sbt assembly
java -cp target/scala-2.11/finatrahelloworld_2.11-1.0.jar com.twitter.server.FitmanAppJSONPatchRequests
# test API
curl -X PATCH -H "Content-Type:application/json-patch+json" \
    -d '{"op":"copy","from":"/fruit","path":"/veggie"}' \
   localhost:8080/jsonPatch

Advanced

Post-advanced API : FitmanAppPostAdvanced.scala

sbt assembly
java -cp target/scala-2.11/finatrahelloworld_2.11-1.0.jar com.twitter.server.FitmanAppPostAdvanced
# test API
curl -X POST -H "Content-Type: application/json" \
    -d '{ "sth": sth}' \
   localhost:8080/1.1/foo

curl localhost:8080/1.1/appendMultiplePrefixed

curl localhost:8080/1.1/freestyleWithHeader

curl -X POST -H "Content-Type: application/json" \
-d '{ "x": 100}' \
localhost:8080/post_basic/plus_100

curl -X POST -H "Content-Type: application/json" \
-d '{ "x": 100, "y":88}' \
localhost:8080/post_basic/sum

Test via python

sbt assembly
java -cp target/scala-2.11/finatrahelloworld_2.11-1.0.jar com.twitter.server.FitmanAppPostAdvanced

python api/run.py --httpRequest get --endPoint http://localhost:8080/hello
python api/run.py --httpRequest get --endPoint http://localhost:8080/1.1/plaintext

Build

sbt compile
sbt assembly

Run

  • dev

Development

  • dev

Ref

About

Build REST API via Scala via Finatra framework

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published