Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Siddhartha Gadgil
    @siddhartha-gadgil
    Thanks @lihaoyi . Everything migrated successfully.
    Li Haoyi
    @lihaoyi
    great!
    jodersky
    @jodersky
    @lihaoyi I'm currently porting cask to Dotty and while looking through the macros I noticed this @doc annotation, and AFAICT it's not documented anywhere. What's the plan for this? Can I ignore this for the dotty port? (at least for now)
    Li Haoyi
    @lihaoyi
    @jodersky sure feel free to ignore it for now, we can come back and flesh it out later
    oneengineer
    @oneengineer
    It seems I can only access the cask website from localhost, how can I expose it to public
    Ah, I just figured out, I need to override host to "0.0.0.0"
    jodersky
    @jodersky
    @noelwelsh I have a WIP version of a dotty port working lihaoyi/cask#35. Some features are still missing (see the comments in the PR) but you can already mostly use it for local testing
    argh, looks like scala-requests isn't published to maven yet. You'll need to publish that too if you do plan on using the dotty version of cask locally (latest master works on Dotty, just isn't published to maven yet)
    Noel Welsh
    @noelwelsh
    Nice one! Thanks!
    kurgansoft
    @kurgansoft

    Hi All,

    In my project I'm trying to upgrade cask from 0.6.7 to 0.7.5

    The main entry point for my app looks something like this:

    object Launcher extends cask.Main {
      override def allRoutes: Seq[Routes] = Seq(MyCustomRoute())
    }

    MyCustomRoute (which implements cask.main.Routes) is relatively complex, has several endpoints, static files, static resources, websockets. But it does work with cask 0.6.7.

    But as I am trying to upgrade to 0.7.5, as I launch my application I get the below error:

    Receiver class MyCustomRoute does not define or inherit an implementation of the resolved method 'abstract void cask$main$Routes$setter$actorContext_$eq(castor.Context$Simple)' of interface cask.main.Routes.

    Any idea how to track down where the error could be?

    Li Haoyi
    @lihaoyi
    seems like a classpath version conflict; can you make sure you've upgraded cask to 0.7.5 throughout your application, and that you're doing a clean compile?
    kurgansoft
    @kurgansoft
    It turns out it did work launching it from the command line. After generating the IDEA project again, launching it from IntelliJ works now as well.
    Li Haoyi
    @lihaoyi
    sounds like intellij's caches were stale; wouldn't be the first time
    oneengineer
    @oneengineer
    How can I make paramter id optional ?
      @cask.get("/tasks")
      def taskPage(id:Option[String])
    It tells me lack of id
    Noel Welsh
    @noelwelsh
    @cask.get("/tasks/:id")
    def taskPageWithId(id: String) = ???
    
    @cask.get("/tasks")
    def taskPageWithoutId() = ???
    oneengineer
    @oneengineer
    the doc says I can use option[T]
    I cannot use override, the combination would kill me
    oneengineer
    @oneengineer
    Also is there any to bypass the parameter check? I.e. I can write extra paramter in the URL than parameters in function without causing error?
    Li Haoyi
    @lihaoyi
    how about id: Option[String] = None or id: String = null
    oneengineer
    @oneengineer
    thanks ! it does the trick
    Markus Joschko
    @jocsch
    What is the best strategy to restrict file upload size?
    Alexandros Bantis
    @ambantis
    Hi, please excuse the noob question. Is it possible to have multiple route objects/classes/traits that are mixed together into a single MainRoute?
    Alexandros Bantis
    @ambantis

    ah ... I implemented it as

    object Foo extends cask.Routes { ... }
    object Bar extends cask.Routes { ... }
    object Application extends cask.Main {
      override def allRoutes = Seq(Foo, Bar)
    }

    Would this be the recommended approach?

    Li Haoyi
    @lihaoyi
    yeah
    or case classes if you want to inject things into them
    jodersky
    @jodersky
    FYI: cask 0.7.6 is now available on maven central, for Scala 2.13 and Dotty 0.27.0-RC1 !
    discobaba
    @uncleweirdo_twitter
    Since I'm a Haoyi fan, I thought I'd try Cask, but was disappointed to find the examples on https://www.lihaoyi.com/cask/ don't run ...
    jodersky
    @jodersky
    that's too bad. But without more information it will be hard to help...
    discobaba
    @uncleweirdo_twitter
    Oh, I figured they failed universally.
    ./mill -w app.runBackground
    Compiling /private/tmp/minimalApplication-0.7.6/build.sc
    build.sc:4: object creation impossible. Missing implementation for:
    def crossScalaVersion: String // inherited from trait CrossModuleBase
    object app extends CrossScalaModule{
    ^
    Compilation Failed
    Li Haoyi
    @lihaoyi
    @jodersky looks like your cross-building for Dotty change broke it, probably just need to tweak the example project mangler over here https://github.com/lihaoyi/cask/blob/master/build.sc#L251 to make it mangle the CrossScalaModule back into a normal ScalaModule
    (we could also make it insert a def crossScalaVersion field, but I think for an example project the non-cross module is simpler and more newbie friendly)
    jodersky
    @jodersky
    oh yes, it seems that indeed the addition of cross-building broke it
    I'll fix it
    Li Haoyi
    @lihaoyi
    will need to tag another numbered version in order to update the example downloads
    jodersky
    @jodersky
    This should do it lihaoyi/cask#36
    I checked locally that the generated examples work. Let me know if you'd still like to review, otherwise I'll publish a new release a bit later
    thanks for the pointer about what broke!
    Li Haoyi
    @lihaoyi
    shipit
    discobaba
    @uncleweirdo_twitter
    Wow, thanks for the quick service;-)
    Jason Zou
    @jasonzou
    Screen Shot 2020-10-20 at 11.38.17 AM.png
    I am new to cask. I downloaded twirl-0.7.7.zip and tried to run. I got the following message:
    Cannot resolve app. Did you mean all?
    Watching for changes to 2 paths... (Ctrl-C to exit)
    jodersky
    @jodersky
    looks like my previous fix didn't catch that one. I'll need to review it again
    in the mean time, can you try using another example? The scalatags example works
    lukas-mi
    @lukas-mi

    Hello,

    I've been trying out cask and so far loving the simplicity!

    However, I have a question regarding how to shut down cask application correctly. Scenario is this: in the main object (extends cask.Main) message consumer is created, this consumer runs in the main's thread. It basically polls a queue (java.util.concurrent.BlockingQueue) and does some work. Now in the router object (extends cask.Routes) on every request its body is put into this queue. So for example if queue consumer fails and throws an exception, I'd like for the whole application to stop. Not sure if it's a good approach but I've tried executionContext.shutdown from within object extending cask.Main but routes are still being served and JVM does not exit. So what's the correct way here?

    Li Haoyi
    @lihaoyi
    Can you look at what the Cask test suites do?
    IIRC they shut down the server when done
    lukas-mi
    @lukas-mi
    Thanks for the response, found the usage of underlying Undertow server. So I guess I'll just override cask.Main.main and create the server directly. Though it would be nice for DefaultHandler to be exposed publicly without needing to extend cask.Main because now I only need defaultHandler from it :).
    Li Haoyi
    @lihaoyi
    yeah cask.Main is a bit of an opaque blob; I never really thought about providing a nice API, if you have some ideas PRs are welcome. But for now, it's hopefully small enough you can deconstruct it and use the pieces you care about directly