ldipotetjob / restfulinplay

we play here with some alternatives building RESTful Web Services in play framework with Scala language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

captura de pantalla 2017-10-07 a las 15 09 49

Implementing Restful services in scala ecosystem with Play Framework

This project is a proof of concept about the basic architecture of a Play Framework multi module project.

What will you find here?

  • A basic multi module architecture that will let you implement and process Restful WebServices in Scala programming language, it can be a template for any multi module Play Framework project.

  • An implementation of HTTP protocol Content-Negotiation:

    • Accept
    • Content-Type
    • You can add here any other header fields involved in content-negotiation.
  • How generate CSV response depending of Content-Negotiation:

    • Implementing custom template using twirl engine for return a CSV file depending of the Accept header field.
    • Implement at the same time json responses.
  • How implement TDD in our development process:

    • We have create the base of Spec with FlatSpec style: We have NOT covered the whole lines of code but we have created enoguh test suites for give you an idea of how to make with the rest. We have covered at least Controllers, action,implicit conversions and services.

What you will not find here, but you should

  • ErrorHandler implementation as indicate play framework specification.
  • Internationalization of messages.
  • LogHandler:
    • Although we register some log, must exist a log handler, which could be a trait. This trait could be implemented by all those classes that, at some point, can generate a log.

Requirements, Installation, Launching, Testing

Requirements

  • jdk 1.7+ -> how check java version: java -version
  • scala 2.11.x -> how check scala version: scala -version
  • sbt 0.13.11+ -> how check sbt version: sbt about

Installation

  • clone repository
  • go to root project
  • type in terminal: sbt -Dconfig.resource=development.conf run

video: running sbt

Launching

You have several rest sevices to call:

This is the route file and it has commented several examples on how call all services exposed in this project. The commented examples has the following structure:

# pattern:

# example:

You can paste the # example: in your terminal in case of curl o in your browser in case http

And access to swagger link of our services: http://localhost:9000/apirest/assets/dist/index.html you can change dns name and port number in your application.conf for your specific environment.

Testing

  • go to root project
  • type in terminal: sbt test

video: running test

The basic information is here on gitHub and contains the main project information.

Each package in the source code has a file (package.txt) that explains the fundamentals of that specific package.



https://mojitoverdeintw.blogspot.com

About

we play here with some alternatives building RESTful Web Services in play framework with Scala language

License:Other


Languages

Language:Scala 98.3%Language:HTML 1.6%Language:JavaScript 0.1%