Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 22 12:43
    magnolia-k commented #969
  • Sep 22 11:45
    magnolia-k commented #969
  • Sep 22 11:43
    magnolia-k commented #969
  • Sep 22 11:43
    magnolia-k commented #969
  • Sep 22 08:31
    takezoe commented #969
  • Sep 21 14:51
    magnolia-k commented #964
  • Sep 21 12:27
    magnolia-k commented #969
  • Sep 16 17:56
    rvanheest commented #969
  • Sep 16 02:15
    marti1125 closed #628
  • Sep 10 03:21
    magnolia-k review_requested #974
  • Sep 09 14:15
    popojargo synchronize #974
  • Sep 09 14:06
    takezoe labeled #974
  • Sep 09 13:22
    popojargo edited #974
  • Sep 09 13:22
    popojargo opened #974
  • Sep 09 10:58
    jnatten commented #765
  • Sep 08 23:18
    magnolia-k commented #969
  • Sep 06 20:54
    popojargo opened #973
  • Sep 06 07:45

    magnolia-k on 2.7.x

    sbt 1.3.0 Merge pull request #972 from xu… (compare)

  • Sep 06 07:45
    magnolia-k closed #972
  • Sep 06 05:35
    xuwei-k opened #972
Oliver Ruebenacker
@curoli
Then I go to http://0.0.0.0:8080/blub and I get HTTP 404 "Not found".
Thanks!
Oliver Ruebenacker
@curoli
OK, I found the issue. Somewhere the API gets "mounted" which adds another path component to the URL.
James Earl Douglas
@earldouglas_gitlab
Is there a way to handle errors with each route handler, rather than with the blanket error { } route handler?
Simple use case: two different routes allow file uploads. Either one can break with a SizeConstraintExceededException. When this happens, I want to respond differently within each route.
Naoki Takezoe
@takezoe
@earldouglas_gitlab Catch an exception in a handler and call pass(). If pass() is called, Scalatra tries to find a next handler.
http://scalatra.org/guides/2.6/http/routes#passing
James Earl Douglas
@earldouglas
@takezoe Perfect; thanks!
Steve Fosdal
@sfosdal
Does anyone know of any issue with using @ApiModelProperty(access = "hidden”) to hide a field from being exposed in swagger?
I’m trying this:
import org.scalatra.swagger.annotations._

@ApiModel(description = "some description")
case class Demo(strings: Seq[String]) {

  @ApiModelProperty(access = "hidden") lazy val foo: String = {
    "this part doesn't really matter"
  }

}
but the lazy val is documented. :/
Steve Fosdal
@sfosdal
making foo a def accomplishes the documentation part of what I want, but foo, in general doesn’t need to be re-evaluated every time
magnolia
@magnolia-k
In the current implementation, it seems that there is no logic using access
Calvin Ference
@vezril
Hey guys, quick question, what would be the way in scalatra to send out an HTTP request to a REST api?
TATSUNO Yasuhiro
@exoego
Do you mean cause scalatra server to send HTTP request to some external REST APIs?
Or you want to send HTTP request to REST APIs on your scalatra server?
James Earl Douglas
@earldouglas_gitlab
Is there something in Scalatra that forces a response's charset? I have get ("/") { contentType = "image/png" ; myImageInputStream }, and no matter what I try, I can't get the Content-Type header to be image/png. It always comes out as image/png;charset=UTF-8.
James Earl Douglas
@earldouglas_gitlab
Adding response.characterEncoding = None appears to solve the problem.
James Earl Douglas
@earldouglas_gitlab
Tomcat 9 shits the bed when the character encoding is unset. Is anyone aware of a guide for configuring Tomcat to allow Content-Type: image/png without a charset?
James Earl Douglas
@earldouglas_gitlab
Is Scalatra just incapable of serving binary data?
James Earl Douglas
@earldouglas_gitlab
I'm completely stuck here. Maybe Stack Overflow can help: https://stackoverflow.com/questions/57317370/
Naoki Takezoe
@takezoe
I tried fixing it several years ago, but it has been reverted: scalatra/scalatra#332
Naoki Takezoe
@takezoe
One possible solution is setting ContentType and then writing binary directory to HttpServletResponse.
like this:
get("/image") {
  contentType  = "image/png"
  val out = response.getOutputStream

  // write binary to OutputStream here
  ...

  () // return Unit
}
Naoki Takezoe
@takezoe
I also answered on StackOverflow. Hope it will help you! @earldouglas_gitlab
James Earl Douglas
@earldouglas
Thanks, @takezoe. Unfortunately this doesn't solve the problem; charset=utf-8 still gets appended to the Content-Type header.
get("/image") {   
  contentType  = "image/png"   
  val out = response.getOutputStream   
  out.write("foobar".getBytes())   
  ()
}
$ curl localhost:8080/image --head
HTTP/1.1 200 OK
Date: Sun, 04 Aug 2019 12:35:51 GMT
Content-Type: image/png;charset=utf-8
Content-Length: 6
Server: Jetty(9.4.8.v20171121)
Naoki Takezoe
@takezoe
@earldouglas Try to call response.flushBuffer() after writing binary data.
James Earl Douglas
@earldouglas
Great idea, but unfortunately didn't work.
Thanks again for the help. It's not an urgent issue for me anymore, as I've migrated off of Scalatra.
Ingemar Ådahl
@ingemaradahl

Hi, I'm having trouble understanding how to fully support passing urls as route parameters. Based on

get("/encoded-uri/:name") {
  params("name")
}

from RouteTest.scala, the following test fails:

get("/encoded-uri/https%3A%2F%2Fexample%2Ftest%3F%253Ffoo%3Dbar") {
  status should equal(200)
  body should equal("https://example/test?%3Ffoo=bar")
}
It smells a lot like scalatra/scalatra#52 which talks about doing special things for ?, /, and # characters. For reference %3F decodes to ?, and %253F decodes to %3F
So my problem is that the name parameter is sort of decoded "twice". The body in the test above actually contains https://example/test??foo=bar which is incorrect
Naoki Takezoe
@takezoe
@ingemaradahl Looks like a bug? Could you file an issue on GitHub?
Ingemar Ådahl
@ingemaradahl
Naoki Takezoe
@takezoe
Thanks!
Ignacio Javier Fernández Soto
@ignaciofernandezsoto
Hey there! I have a question regarding scalatra. Is there a way to reutilize the url path defined in the servlet?
I have get("/notifications"), get("/notifications/:user_id"), post("/notifications/:user_id"), put("/notifications/:user_id")
I'd like to have something class level, like override def basePath = "/notifications". Is there a way to do such a thing?
Naoki Takezoe
@takezoe
@ignaciofernandezsoto Mapping your ScalatraServlet to /notifications/* doesn't work?
Ignacio Javier Fernández Soto
@ignaciofernandezsoto
Hey Naoki, thank you very much! Got it working
Jonas Natten
@jnatten
Is there an ETA for when a version will be available for 2.13?
Anyone successfully using the 2.7RC in production?
Naoki Takezoe
@takezoe
GitBucket already uses Scalatra 2.7RC1 in order to support Scala 2.13.
Jonas Natten
@jnatten
Hmm, might consider doing the same then if there is no known eta. Thanks :)
Naoki Takezoe
@takezoe
There isn't serious issue in Scalatra 2.7 with Scala 2.13 so far. At first, we planned to include more features in Scalatra 2.7, but we don't have enough resources to complete the our initial plan. So, it may be a time to release Scalatra 2.7.0.
john-roj
@john-roj
Any success on using sbt 1.3.0??? I am getting [error] sbt.librarymanagement.ResolveException: Error downloading org.scalatra:scalatra_2.12:[2.6.50000,2.6.60000) [error] No version found for VersionInterval(Some(Version(2.6.50000)),Some(Version(2.6.60000)),true,false)
Naoki Takezoe
@takezoe
@john-roj What's your build.sbt?
john-roj
@john-roj
I don't think it has anything special... sbt 1.3.0 changes "library management" with coursier. if I apply the ThisBuild / useCoursier := false it works, just wondering why coursier can't find the dependency I am adding scalatra jars under
libraryDependencies ++=  {  val ScalatraVersion     = "2.6.5"
"org.scalatra"               %% "scalatra"                        % ScalatraVersion exclude ("org.slf4j", "slf4j-api"),
        "org.scalatra"               %% "scalatra-scalate"                % ScalatraVersion,
        "org.scalatra"               %% "scalatra-json"                   % ScalatraVersion,
        "org.scalatra"               %% "scalatra-swagger"                % ScalatraVersion,
...