scalatra

Generating Json string using Json4S from a list containing Some and None values

夙愿已清 提交于 2019-12-19 09:43:39
问题 I am using Scalatra, which in turn uses Json4S to generate Json string. I receive ["A","B"] for List(Some("A"),None,Some("B")) I would like to receive ["A",undefined,"B"] How can this be fixed ? 回答1: undefined is not a valid json value, even though it is valid in javascript. From rfc4627 (application/json): A JSON value MUST be an object, array, number, or string, or one of the following three literal names: false null true (no mention of undefined) However this is fairly straight-forward to

Slick: Difficulties working with Column[Int] values

时光怂恿深爱的人放手 提交于 2019-12-13 19:26:23
问题 I have a followup to another Slick question I recently asked (Slick table Query: Trouble with recognizing values) here. Please bear with me!! I'm new to databasing and Slick seems especially poor on documentation. Anyway, I have this table: object Users extends Table[(Int, String)]("Users") { def userId = column[Int]("UserId", O.PrimaryKey, O.AutoInc) def userName = column[String]("UserName") def * = userId ~ userName } Part I I'm attempting to query with this function: def findByQuery(where:

ScalatraServlet with AkkaSupport with GZipSupport

蹲街弑〆低调 提交于 2019-12-13 06:43:48
问题 I'm trying to use Scalatra with AkkaSupport and the newly introduced (2.2.0 RC2) GZipSupport. It fails and I'm trying to figure out if I'm doing something wrong, before I file a bug report. The code is the default Scalatra/Akka example, including the GZipSupport trait: package com.myapp import _root_.akka.dispatch._ import _root_.akka.actor._ import org.scalatra._ import org.scalatra.akka.AkkaSupport class myappServlet extends ScalatraServlet with AkkaSupport with GZipSupport { implicit val

Jetty config without resourceBase

拥有回忆 提交于 2019-12-12 01:36:18
问题 I have a Scalatra with Jetty and it is serving REST API at the moment. No static context served at all. However, it seems I cannot skip setting resourceBase without getting java.lang.IllegalStateException: No resourceBase or war set for context Do I have to point it to some empty directory or is there some other option? 回答1: A resourceBase is required, and it is used for more than just static content. It's also the location for configuration that the ServletContext needs. Point it at an empty

Slick table Query: Trouble with recognizing values

落花浮王杯 提交于 2019-12-11 19:33:47
问题 Can anyone tell me why in this case: Query(Users) foreach {case (userId, userName) => println(userId + ", " + userName) } Scala recognizes userId, but in this case: val l = List[(Int, String)]() Query(Users) foreach { case (userId, userName) => l::(foo(List[(userId, userName)])) } it doesnt? (as in, the userId on the right of the "=>" is recognized in the second case but not the first) Users is a slick-mounted database that looks like this: object Users extends Table[(Int, String)]("Users") {

Scalatra app on Openshift - setting Jetty IP

允我心安 提交于 2019-12-10 18:35:42
问题 I'm trying to deploy a minimal Scalatra application on Openshift with DIY cartridge. I've managed to get SBT working, but when it comes to container:start , I get the error: FAILED SelectChannelConnector@0.0.0.0:8080: java.net.SocketException: Permission denied Apparently, embedded Jetty tries to open socket at 0.0.0.0, which is prohibited by Openshift (you can only open ports at $OPENSHIFT_INTERNAL_IP). How can I tell Jetty exactly which IP I need it to listen? 回答1: Yes you are right about

How to Install conscript in Windows

五迷三道 提交于 2019-12-10 11:35:20
问题 Conscript is needed for giter8 to check out project templates directly from Github and as Scalatra.org states is recommended way to generate Scalatra project skeletons. When conscript-0.4.4.jar is ran error "Error downloading sbt-launch-0.13.0 happens". 回答1: sbt-launch-0.13.0.jar was removed from sbt site. so you have to: Install sbt from the official site. Copy "sbt-launch.jar" from "C:\Program Files (x86)\sbt\bin" into "C:\Users{Username}.conscript" Make another copy of "sbt-launch.jar" in

Scala: Replace newline, tab and return sequences from string

和自甴很熟 提交于 2019-12-09 07:54:10
问题 I have a string of HTML that I'm copy pasting into a String object that looks something like the following: val s = """<body> <p>This is a test</p> <p>This is a test 2</p> </body""" The problem here is, when I display this string as JSON within the context of a web browser, the output displays literal \n and \t characters to the tune of something like this: "<body>\n <p>This is a test</p>\t <p>This is a test 2</p>\n</body>" Is it possible to perhaps strip all of these escaped sequences from

Declaring a different compile path for CoffeeScript

﹥>﹥吖頭↗ 提交于 2019-12-06 12:57:14
I have a Scalatra app that compiles CoffeeScript, using https://github.com/softprops/coffeescripted-sbt , to a default location, target/scala-2.9.1/resource_managed/main/js . I want to put the generated javascripts somewhere available to me publicly, in a folder called src/main/webapp/coffee , but the example given defaults to `/target/...' resourceManaged in (Compile, CoffeeKeys.coffee)) <<= (crossTarget in Compile)(_ / "your_preference" / "js") My build.sbt: seq(coffeeSettings: _*) // doesn't work //(resourceManaged in (Compile, CoffeeKeys.coffee)) <<= ("src" / "main" / "webapp" / "coffee")

How to keep sbt running (as a daemon process) after executing a command

99封情书 提交于 2019-12-06 04:51:11
I want to launch scalatra server from sbt. How do I do that? The following does launch scalatra: sbt "container:start" But it exits immediately: [info] starting server ... [success] Total time: 2 s, completed Sep 12, 2015 2:39:32 PM > [info] waiting for server to shut down... Most preferably the whole thing would run in a nohup as a daemon process. Don't do it on one line. Use two commands. ./sbt container:start sbt "; <command>; console" does the trick. Note the initial semicolon is required. 来源: https://stackoverflow.com/questions/32544032/how-to-keep-sbt-running-as-a-daemon-process-after