scalatra

Scalatra / Slick and insert IF NOT EXISTS

非 Y 不嫁゛ 提交于 2019-12-01 15:28:10
问题 I am a newbie so hoping for some patience. :) I am trying to populate two tables if a value does not exist. Basically I have: TABLE b ( id VARCHAR(254) PRIMARY KEY NOT NULL ); TABLE d ( id VARCHAR(254) PRIMARY KEY NOT NULL, relay INT NOT NULL, FOREIGN KEY ( relay ) REFERENCES b ( id ) ); so I am trying to write a function that populates the two tables with a new value, if it doesn't exist, or ignores it otherwise... of course wrapped in a transaction: IF (NOT EXISTS(SELECT * FROM b where id=

How to implement a REST Web Service using Akka?

旧时模样 提交于 2019-11-29 22:18:19
I intend to implement a pure Akka powered REST based Web API. I am not sure about using spray. I would consider using Scalatra if it is any good. Basically I am interested in using the concurrency benefits of Scala Actor model. I don't want the Servlet container to be an hindrance in that process. What can be other options? Update 1: Which is better frontend for implementing REST based on Akka backend? - Spray, Scalatra or Dropwizard or any other? The important thing to realize about Akka is that it's not an all-or-nothing environment. You can, to a large degree, mix and match different

Deserialization of case object in Scala with JSON4S

时光毁灭记忆、已成空白 提交于 2019-11-29 10:40:16
I have some case classes defined like follows: sealed trait Breed case object Beagle extends Breed case object Mastiff extends Breed case object Yorkie extends Breed case class Dog(name: String, breed: Breed) I also have an endpoint defined with Scalatra: post("/dog") { val dog = parsedBody.extract[Dog] ... } I'd like this JSON object: { name: "Spike", breed: "Mastiff" } to deserialize to the appropriate instance of Dog . I'm struggling to figure out how to write a custom deserializer for Breed and register it with JSON4S. You need to write the serializer like below: Serializer : case object

How to implement a REST Web Service using Akka?

痞子三分冷 提交于 2019-11-28 18:50:33
问题 I intend to implement a pure Akka powered REST based Web API. I am not sure about using spray. I would consider using Scalatra if it is any good. Basically I am interested in using the concurrency benefits of Scala Actor model. I don't want the Servlet container to be an hindrance in that process. What can be other options? Update 1: Which is better frontend for implementing REST based on Akka backend? - Spray, Scalatra or Dropwizard or any other? 回答1: The important thing to realize about

Deserialization of case object in Scala with JSON4S

有些话、适合烂在心里 提交于 2019-11-28 03:54:26
问题 I have some case classes defined like follows: sealed trait Breed case object Beagle extends Breed case object Mastiff extends Breed case object Yorkie extends Breed case class Dog(name: String, breed: Breed) I also have an endpoint defined with Scalatra: post("/dog") { val dog = parsedBody.extract[Dog] ... } I'd like this JSON object: { name: "Spike", breed: "Mastiff" } to deserialize to the appropriate instance of Dog . I'm struggling to figure out how to write a custom deserializer for

Standalone deployment of Scalatra servlet

跟風遠走 提交于 2019-11-27 21:49:32
问题 I implemented a Scalatra servlet and now want to create an executable jar, just like described in this tutorial: http://www.scalatra.org/2.2/guides/deployment/standalone.html I use IntelliJ IDEA with the Scala plugin for development and sbt to build and run my servlet (I used sbt-idea to generate the project files). My problem is that the jetty packages that the JettyLauncher in the tutorial uses cannot be found when I try to compile my project. UPDATE: Using Matt's answer I was able to