Questions tagged [scalatra]

Scalatra is a tiny Scala web framework, inspired by Sinatra.

Scalatra is a microframework written in Scala. It is a port of the Sinatra framework written in Ruby. Scalatra can be expanded into a minimal but full-featured model-view-controller web framework.

Website: http://scalatra.org/

Source: https://github.com/scalatra/scalatra

309 questions
1
vote
1 answer

Scalatra: printing the HTTP status code of all APIs

I have a scalatra servlet with multiple REST APIs. For logging purposes, I use the after() method to print out the return status code after each API is called. after() { logger.info("request {} {} returned with status code {}", request.getMethod,…
Aliza
  • 734
  • 1
  • 10
  • 25
1
vote
1 answer

BigDecimal precision in Scala case class

I am using SORM as ORM in Scalatra application. I use Create as the initMode so that the tables are created automatically. I have a BigDecimal field as part of a case class, as below: case class Invoice(invoiceId: String, invoiceAmount:…
Mubin
  • 4,192
  • 3
  • 26
  • 45
1
vote
0 answers

Using Scalatra's halt() in a function

My Scalatra web service has a lot of GET routes. Everyone of them needs nearly identical code for caching and for authentication/authorization, and repetitive code is stupid. I want to refactor that code with the help of implicit parameters into…
5-to-9
  • 649
  • 8
  • 16
1
vote
0 answers

Convert JOOQ results to a Map

I am developing a Web API using Scala with Scalatra and JOOQ. I would like to deal with Maps instead of Records, Case Classes etc Using JacksonJsonSupport to automatically serialize my data to JSON : get("/test") { val r = DBManager.query…
prog keys
  • 687
  • 1
  • 5
  • 14
1
vote
1 answer

Scalatra does not mount new service

I am trying to mount the service to scalatra but after compiling and starting the app GET /logging is not recognized by scalatra ScalatraBootstrap.scala import org.scalatra._ import javax.servlet.ServletContext class ScalatraBootstrap extends…
Sam
  • 2,761
  • 3
  • 19
  • 30
1
vote
0 answers

Run Scalatra application on multiple ports

I am building an application using the Scalatra framework, and need to expose one external facing endpoint which I would like to mount on a different port. I am having trouble seeing how to configure my application to do so class ScalatraBootstrap…
user1875195
  • 968
  • 4
  • 8
  • 22
1
vote
1 answer

Scala + Reactivemongo: Controling custom readers/writers for REST-API

I am working on a REST-API implemented in Scalatra and using reactivemongo. My persistent model is implemented using case classes and a thin repository layer uses the common approach for bson<->class mapping via DocumentReader/DocumentWriter (via…
bennidi
  • 2,092
  • 21
  • 27
1
vote
1 answer

Unable to get JSON response in Scalatra (using JPA for ORM)

I am using JPA for data modeling in Scalatra. I have a data model where in one class has a variable as an object of another class and that class in turn has a list of objects of a different class (a transitive relation). The 3 classes are as shown -…
user5145641
  • 11
  • 1
  • 2
1
vote
0 answers

Scalatra, Atmosphere, and sending messages to clients from outside the message handler

I'm currently reading through the official Scalatra documentation, particularly the guide on using Scalatra with Atmosphere. That page explains how to use Scalatra and Atmosphere to write a WebSocket based application which responds to incoming…
Ming
  • 1,613
  • 12
  • 27
1
vote
3 answers

How to serialize object type to JSON in Scalatra?

I am a newbie in Scalatra. I have a servlet with JacksonJsonSupport which serves REST endpoint with list of objects. class OperationsController extends MyappStack with JacksonJsonSupport { before() { contentType = formats("json") } …
Dariusz Mydlarz
  • 2,940
  • 6
  • 31
  • 59
1
vote
1 answer

Scalatra, Handling POST request with Gzip encoding

I have a Scalatra API with a POST method, which is invoked by an external API that sends gzip encoded messages. But I am unable to read the body of the post request, and when I try to read the body of POST or try to decompress it, I get the…
armulator
  • 1,269
  • 2
  • 12
  • 16
1
vote
0 answers

Cannot get upickle working with scala.js in a scalatra servlet

When I try calling upickle.write from anywhere in a servlet I get an exception. If for example I do upickle.write("x") I get the exception below. Any suggestions? java.lang.ClassCastException: java.lang.String cannot be cast to…
user79074
  • 4,937
  • 5
  • 29
  • 57
1
vote
2 answers

Scalatra Render Page Cannot Determine Template Processor

I've tried to render a page index.ssp in my scalatra controller, but it shows me an error: ssp("index") //Error : Template file extension missing. Cannot determine which template processor to use. My Servlet extends ScalatraServlet with…
Dineshkumar
  • 4,165
  • 5
  • 29
  • 43
1
vote
0 answers

How to make sessions persistent in Scalatra?

I have a webapp using the Scala-based Scalatra web framework. The problem is, anytime the application is re-deployed, or anytime the app-server is rebooted, all session data is lost. This means (to name one downside) users must re-login every time…
Chris W.
  • 1,680
  • 16
  • 35
1
vote
1 answer

Have Scalatra exit if LifeCycle added with Context.setInitParameter throws exception

I want a Scalatra servlet to exit if initialization fails so that upstart/systemd/whatever can restart it on failure. Drawing from examples on the web, we have a LifeCycle that does some initialization, but occasionally fails class Bootstrap extends…
user364952
  • 570
  • 4
  • 10