Giter Site home page Giter Site logo

finatrahelloworld's Introduction

FinatraHelloWorld

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

Quick start

Quick start

Basics

Get API : FitmanAppGet.scala

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

Post API : FitmanAppPost.scala

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

Redirect API : FitmanAppRedirect.scala

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

finatrahelloworld's People

Contributors

yennanliu avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.