Skip to content

Commit

Permalink
0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyi committed Jul 20, 2020
1 parent 3209fd8 commit d1f181b
Show file tree
Hide file tree
Showing 33 changed files with 64 additions and 38 deletions.
10 changes: 5 additions & 5 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ object cask extends CaskModule {
def ivyDeps = Agg(
ivy"org.scala-lang:scala-reflect:${scalaVersion()}",
ivy"io.undertow:undertow-core:2.0.13.Final",
ivy"com.lihaoyi::upickle:1.1.0"
ivy"com.lihaoyi::upickle:1.2.0"
)
def compileIvyDeps = Agg(ivy"com.lihaoyi::acyclic:0.2.0")
def scalacOptions = Seq("-P:acyclic:force")
Expand All @@ -69,22 +69,22 @@ object cask extends CaskModule {
def ivyDeps = Agg(
ivy"com.lihaoyi::sourcecode:0.2.1",
ivy"com.lihaoyi::pprint:0.5.9",
ivy"com.lihaoyi::geny:0.6.0"
ivy"com.lihaoyi::geny:0.6.2"
)
}

object js extends UtilModule with ScalaJSModule{
def platformSegment = "js"
def scalaJSVersion = "0.6.33"
def ivyDeps = super.ivyDeps() ++ Agg(
ivy"com.lihaoyi::castor::0.1.1",
ivy"com.lihaoyi::castor::0.1.4",
ivy"org.scala-js::scalajs-dom::0.9.7"
)
}
object jvm extends UtilModule{
def platformSegment = "jvm"
def ivyDeps = super.ivyDeps() ++ Agg(
ivy"com.lihaoyi::castor::0.1.3",
ivy"com.lihaoyi::castor::0.1.4",
ivy"org.java-websocket:Java-WebSocket:1.4.0"
)
}
Expand All @@ -95,7 +95,7 @@ object cask extends CaskModule {
def testFrameworks = Seq("utest.runner.Framework")
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2"
ivy"com.lihaoyi::requests::0.6.5"
)
}
}
Expand Down
10 changes: 10 additions & 0 deletions cask/src/cask/main/Main.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package cask.main

import java.util.concurrent.Executors

import cask.endpoints.{WebsocketResult, WsHandler}
import cask.model._
import cask.internal.{DispatchTrie, Util}
Expand All @@ -11,6 +13,8 @@ import io.undertow.server.{HttpHandler, HttpServerExchange}
import io.undertow.server.handlers.BlockingHandler
import io.undertow.util.HttpString

import scala.concurrent.ExecutionContext

/**
* A combination of [[cask.Main]] and [[cask.Routes]], ideal for small
* one-file web applications.
Expand All @@ -33,6 +37,12 @@ abstract class Main{
def host: String = "localhost"
def debugMode: Boolean = true

def createExecutionContext = castor.Context.Simple.executionContext
def createActorContext = new castor.Context.Simple(executionContext, log.exception)

val executionContext = createExecutionContext
implicit val actorContext = createActorContext

implicit def log = new cask.util.Logger.Console()

def routeTries = Main.prepareRouteTries(allRoutes)
Expand Down
5 changes: 1 addition & 4 deletions cask/src/cask/main/Routes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import language.experimental.macros
trait Routes{

def decorators = Seq.empty[cask.router.Decorator[_, _, _]]
implicit val actorContext = new castor.Context.Simple(
concurrent.ExecutionContext.Implicits.global,
log.exception
)
implicit def actorContext: castor.Context
private[this] var metadata0: RoutesEndpointsMetadata[this.type] = null
def caskMetadata =
if (metadata0 != null) metadata0
Expand Down
2 changes: 1 addition & 1 deletion example/compress/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
)
}
}
3 changes: 2 additions & 1 deletion example/compress2/app/src/Compress2.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

case class Compress2()(implicit val log: cask.Logger) extends cask.Routes{
case class Compress2()(implicit val actorContext: castor.Context,
val log: cask.Logger) extends cask.Routes{
override def decorators = Seq(new cask.decorators.compress())

@cask.get("/")
Expand Down
2 changes: 1 addition & 1 deletion example/compress2/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
)
}
}
3 changes: 2 additions & 1 deletion example/compress3/app/src/Compress3.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

case class Compress3()(implicit val log: cask.Logger) extends cask.Routes{
case class Compress3()(implicit val actorContext: castor.Context,
val log: cask.Logger) extends cask.Routes{

@cask.get("/")
def hello() = {
Expand Down
2 changes: 1 addition & 1 deletion example/compress3/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
)
}
}
2 changes: 1 addition & 1 deletion example/cookies/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
)
}
}
2 changes: 1 addition & 1 deletion example/decorated/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
)
}
}
2 changes: 1 addition & 1 deletion example/decorated2/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
)
}
}
2 changes: 1 addition & 1 deletion example/endpoints/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
)
}
}
2 changes: 1 addition & 1 deletion example/formJsonPost/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2"
ivy"com.lihaoyi::requests::0.6.5"
)
}
}
2 changes: 1 addition & 1 deletion example/httpMethods/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
)
}
}
2 changes: 1 addition & 1 deletion example/minimalApplication/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

case class MinimalRoutes()(implicit val log: cask.Logger) extends cask.Routes{
case class MinimalRoutes()(implicit val actorContext: castor.Context,
val log: cask.Logger) extends cask.Routes{
@cask.get("/")
def hello() = {
"Hello World!"
Expand Down
2 changes: 1 addition & 1 deletion example/minimalApplication2/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
)
}
}
2 changes: 1 addition & 1 deletion example/redirectAbort/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
)
}
}
2 changes: 1 addition & 1 deletion example/scalatags/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
)
}
}
2 changes: 1 addition & 1 deletion example/staticFiles/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
)

def forkWorkingDir = build.millSourcePath
Expand Down
2 changes: 1 addition & 1 deletion example/staticFiles2/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
)

def forkWorkingDir = build.millSourcePath
Expand Down
2 changes: 1 addition & 1 deletion example/todo/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
)
}
}
2 changes: 1 addition & 1 deletion example/todoApi/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
)
}
}
2 changes: 1 addition & 1 deletion example/todoDb/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
)
}
}
2 changes: 1 addition & 1 deletion example/twirl/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ trait AppModule extends ScalaModule with mill.twirllib.TwirlModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
)
}
}
2 changes: 1 addition & 1 deletion example/variableRoutes/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
)
}
}
2 changes: 1 addition & 1 deletion example/websockets/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
ivy"org.asynchttpclient:async-http-client:2.5.2"
)
}
Expand Down
2 changes: 1 addition & 1 deletion example/websockets2/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
ivy"org.asynchttpclient:async-http-client:2.5.2"
)
}
Expand Down
3 changes: 2 additions & 1 deletion example/websockets3/app/src/Websockets3.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

case class Websockets3()(implicit val log: cask.Logger) extends cask.Routes{
case class Websockets3()(implicit val actorContext: castor.Context,
val log: cask.Logger) extends cask.Routes{
@cask.websocket("/connect/:userName")
def showUserProfile(userName: String): cask.WebsocketResult = {
if (userName != "haoyi") cask.Response("", statusCode = 403)
Expand Down
2 changes: 1 addition & 1 deletion example/websockets3/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
ivy"org.asynchttpclient:async-http-client:2.5.2"
)
}
Expand Down
3 changes: 2 additions & 1 deletion example/websockets4/app/src/Websockets4.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

case class Websockets4()(implicit val log: cask.Logger) extends cask.Routes{
case class Websockets4()(implicit val actorContext: castor.Context,
val log: cask.Logger) extends cask.Routes{
// make sure compress decorator passes non-requests through correctly
override def decorators = Seq(new cask.decorators.compress())
@cask.websocket("/connect/:userName")
Expand Down
2 changes: 1 addition & 1 deletion example/websockets4/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait AppModule extends ScalaModule{

def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.7.4",
ivy"com.lihaoyi::requests::0.6.2",
ivy"com.lihaoyi::requests::0.6.5",
ivy"org.asynchttpclient:async-http-client:2.5.2"
)
}
Expand Down
14 changes: 14 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ courtesy of EJ Technologies

## Changelog

### 0.7.0

- Make Cask `actorContext` explicitly passed into every Routes case class

### 0.6.5

- Add support for `geny.Writable#httpContentType` and
`geny.Writable#contentLength`

### 0.5.7

- Add endpoints for `delete` and `patch`
- Allow arbitrary HTTP methods

### 0.5.2

- Bump uPickle, Requests versions
Expand Down

0 comments on commit d1f181b

Please sign in to comment.