-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c74e639
commit d85421c
Showing
5 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# bloop and metals | ||
.bloop | ||
.bsp | ||
|
||
# metals | ||
project/metals.sbt | ||
.metals | ||
|
||
# vs code | ||
.vscode | ||
|
||
# scala 3 | ||
.tasty | ||
|
||
# sbt | ||
project/project/ | ||
project/target/ | ||
target/ | ||
|
||
# eclipse | ||
build/ | ||
.classpath | ||
.project | ||
.settings | ||
.worksheet | ||
bin/ | ||
.cache | ||
|
||
# intellij idea | ||
*.log | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea | ||
|
||
# mac | ||
.DS_Store | ||
|
||
# other? | ||
.history | ||
.scala_dependencies | ||
.cache-main | ||
|
||
# general | ||
*.class | ||
|
||
# Scala CLI | ||
.scala-build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//> using lib "com.lihaoyi::ujson:2.0.0" | ||
//> using lib "com.lihaoyi::upickle:2.0.0" | ||
//> using lib "com.lihaoyi::os-lib:0.8.1" | ||
//> using lib "com.softwaremill.sttp.client3::upickle:3.8.0" | ||
|
||
|
||
package scala.toolkit { | ||
import _root_.{os => osLib} | ||
import munit.FunSuite | ||
import junit.framework.TestSuite | ||
import sttp.client3.upicklejson.SttpUpickleApi | ||
|
||
val json = upickle.default | ||
object os { | ||
export osLib.pwd | ||
} | ||
|
||
|
||
object test { | ||
export munit.{FunSuite => Suite} | ||
} | ||
|
||
object http extends SttpUpickleApi{ | ||
|
||
val http = this | ||
|
||
val request = sttp.client3.basicRequest | ||
//val x: UriContext = ??? | ||
export sttp.client3.UriContext | ||
|
||
export sttp.client3.{SimpleHttpClient => Client} | ||
|
||
def client = Client() | ||
|
||
extension (uri: sttp.model.Uri) | ||
def get() = client.send(request.get(uri)) | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//> using lib "org.scalameta::munit::0.7.29" | ||
|
||
import munit.FunSuite | ||
|
||
package scala.toolkit { | ||
object test { | ||
export munit.{FunSuite => Suite} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//> using file "../../modules/platform/src" | ||
|
||
import toolkit.json | ||
import toolkit.os | ||
import toolkit.http.* | ||
|
||
@main def a = | ||
val req = http.request.post(uri"http://ptsv2.com/t/sttp/post").body(Data("ala", 12, Nil)) | ||
http.client.send(req) | ||
println("Done") | ||
println(uri"http://ptsv2.com/t/sttp/post".get().body) | ||
|
||
|
||
case class Data(name: String, age: Int, rooms: Seq[String]) derives json.ReadWriter | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import toolkit.test | ||
import toolkit.json | ||
|
||
class Atest extends test.Suite { | ||
test("Data reserialization"){ | ||
val data = Data("Ala", 31, Seq("main", "kitchen")) | ||
// TODO implicit problems with `read` method | ||
assertEquals(data, json.read[Data](json.write(data))) | ||
} | ||
} |