Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 22 16:06
    magnolia-k closed #964
  • Jan 22 16:05
    magnolia-k closed #969
  • Jan 22 16:04

    magnolia-k on 2.7.x

    Update dependencies Merge pull request #993 from xu… (compare)

  • Jan 22 16:04
    magnolia-k closed #993
  • Jan 21 03:38
    xuwei-k review_requested #993
  • Jan 21 03:38
    xuwei-k opened #993
  • Jan 20 15:48

    magnolia-k on 2.7.x

    Update scalatest to 3.1.0 drop… Merge pull request #992 from xu… (compare)

  • Jan 20 15:48
    magnolia-k closed #992
  • Jan 20 11:04
    xuwei-k opened #992
  • Jan 19 22:18
    treaz edited #196
  • Jan 19 22:18
    treaz opened #196
  • Jan 18 18:14
    treaz commented #123
  • Jan 17 18:33

    takezoe on master

    added import MetricsSupportExte… (compare)

  • Jan 17 18:33
    takezoe closed #195
  • Jan 17 18:00
    treaz commented #194
  • Jan 17 17:59
    treaz commented #123
  • Jan 17 17:58
    treaz opened #195
  • Jan 08 15:21
    takezoe commented #991
  • Jan 08 13:48
    takezoe commented #991
  • Jan 08 13:26
    takezoe commented #194
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,
...
Taras Iagniuk
@taryk
@takezoe hi, could you have a look at my PR when you have a chance please? scalatra/scalatra#979
Taras Iagniuk
@taryk
and a corresponding PR into 2.7.x scalatra/scalatra#980
Naoki Takezoe
@takezoe
@taryk Thanks. Let me take a look. By the way, do you need updating Scalatra 2.6.x? We've already released 2.7.0-RC1, so we don't want to keep enhancing 2.6.x if there isn't strong demand.
Taras Iagniuk
@taryk
@takezoe ah, cool! it would still be nice if you could release 2.6.x, so that we can benefit from the change right now
Naoki Takezoe
@takezoe
This library looks interesting. I wonder if we can replace Scalatra's Swagger support by this library.
Nils Kilden-Pedersen
@nilskp
@takezoe they currently only support Akka HHTP and Http4s. But yeah, it looks interesting.
Naoki Takezoe
@takezoe
I'm trying Tapir now. akka-http / http4s integration is interesting. But it seems to be not able to express all of OpenAPI specification. I think it can't replace Scalatra's Swagger support.
Mahendar
@sparkbymahi08_gitlab
HI all ,I have a requirement to download a zip file from download end point . when you hit the API it should read all the files from a temp folder and it should return as zip file and as response stream .Below is sample code .but this not working .Please let me know how to write this .

post("/users/:download", operation(apiOperationFile
.summary("downlaod the file .")
.parameters(
queryParamString.description("input location details .").optional,
queryParamString.description(" out put location").optional
))) {

  val inloc = params("inlocation")
  val filename =  params("filename")

  contentType = "application/octet-stream"
  response.setHeader("Content-disposition","attachment;filename=" + filename)

  val  directory = new File(inloc)
     if(directory.exists() && directory.isDirectory()) {

val out = response.getOutputStream

      for (file:File <-directory.listFiles()){
        val  inputStream=new FileInputStream(file)
        val arrayByte = new Array[Byte](8096)
        var length=0
        while ({
          length = inputStream.read(arrayByte)
          length >= 0
        }) {
          out.write(arrayByte, 0, length);
        }
        inputStream.close()
      }
       out.flush()
    }

  //  catch (final IOException e) {
     // logger.error("Exception while reading and streaming data {} ", e);

  }

}

Naoki Takezoe
@takezoe
@sparkbymahi08_gitlab Basically, your code looks good if your intention is returning a concatenated files. Have you tried to hit this endpoint by curl or any other http clients? If no, could you try that and see headers and contents of the response.
Miguel Silvestre
@msilvestre

Hi, I'm having some issues. I setted scalatra and manage to test the endpoints successfully using ScalatraFeatureSpec.
However when I do '''jetty:start''' and try to query the service I get the following errors:

curl -X GET http://localhost:8080/task

Requesting "GET /" on servlet "/task" but only have:

    GET /task
    GET /task/:id
    POST /task

Why is that?
My corresponding test is:


  feature("get all tasks") {
    scenario("There are no Tasks") {
      When("User gets all Tasks")
      get("/task") {
        Then("Response should be 200")
        status should equal(200)
        And("body is empty")
        body should be("{}")
      }
    }
Miguel Silvestre
@msilvestre
Ok, nevermind, It was because I was creating the servlet with context.mount(new TasksServlet, "/task")
And on the servlet I was also setting /task on the methods. So it will only work for: http://localhost:8080/task/task
Horia Constantin
@treaz
@takezoe, regarding the scalatra-website 2.7 docs. Should we have a new branch for the 2.7 and merge it into master once 2.7 is out, or just create the 2.7 directory, work in it and it will get published on the website when 2.7 is out?
Horia Constantin
@treaz
how does this look? scalatra/scalatra-website#195
Naoki Takezoe
@takezoe
@treaz Since we already published 2.7-RC, I think we can publish 2.7 docs anytime. Maybe the process should be below:
  • Create 2.7 branch, then create 2.7 directory and copy 2.6 docs to 2.7 directory on 2.7 branch
  • Update 2.7 docs on 2.7 branch, then create a pull request
  • Merge into master, then publish the website
Naoki Takezoe
@takezoe
And scalatra/scalatra-website#195 looks good! Thanks!
Horia Constantin
@treaz
@takezoe do you have a couple of minutes to checkout why hugo serve is not showing me anything when I click on the scalatra-website top links (master branch)?
Horia Constantin
@treaz
hugo version: v0.62.2/extended darwin/amd64
Naoki Takezoe
@takezoe
@treaz I tried Huge v0.36.1, but it didn't work too. Hugo v19.0 is used for building the website on TravisCI: https://github.com/scalatra/scalatra-docbuild/blob/dcb75b67d83d1a4498c837c1242aa89dbef9ccf6/.travis.yml#L17
It's too old. We might have to upgrade Huge.
Horia Constantin
@treaz
I'll look into it these days... in the meanwhile, I'll raise an issue on scalatra website.