Using REST web services as a data source for an elevator?

Is there a way to use a web service (REST in this case) as a data source for a Lift application? I can find a few tutorials / examples of using Lift to provide a REST API, but in my case the data is placed elsewhere and exported as a REST web service. Thanks to the pointers to the document.

Thanks Jeff

+4
source share
4 answers

This is not related to the elevator. There are already many different pieces of information:

  • The HttpClient library, as already suggested,
  • or Dispatch Scala library for accessing HTTP services
  • information on how to cache data in Scala in various ways, if you need it

Think about caching completely, it is usually a good choice if your application generates a lot of requests and you can afford caching. Caching will allow you to achieve many goals:

  • reduce response time, since you are not dependent on a remote service (if you perform synchronous data processing)
  • avoid denial of service in the event of the death of a remote service. Otherwise, your application will generate many sockets for reading data and output resources (either sockets, or threads, or something else).
  • do not exceed the SLA of the remote service, as many services limit the number of requests that you are allowed to pefrorm for a certain period of time.

So, you can just sit and stack these things to get this.

+2
source

If you really want to be fantastic, you can create a Record implementation for a REST-based data source. There is already one of them that works with CouchDB. Using the lift-couchdb module, interaction with CouchDB is abstracted, and all you are dealing with is the Scala code. There is a short wiki page with instructions on how to get started with lift-couchdb here:

http://www.assembla.com/wiki/show/liftweb/CouchDB

The corresponding source code files are available here:

http://github.com/lift/lift/tree/master/framework/lift-persistence/lift-couchdb/src/main/scala/net/liftweb/couchdb/

Using the Record interface gives you access to a variety of attributes that you use to ensure minimal code writing, such as creating HTML forms, providing life-cycle-based calls, and convenient intercepts for verification.

+1
source

I put the scala layer on top of the HttpClient and then used it. I was going to put this on github for some time.

0
source

I use Dispatch (which is a wrapper around HttpClient) to make REST calls. It looks beautiful and simple.

0
source

Source: https://habr.com/ru/post/1306257/


All Articles