Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gate
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openmole
gate
Commits
f88c6982
Commit
f88c6982
authored
Aug 18, 2014
by
Mathieu leclaire
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
to autowire and upickle 0.2.1
parent
1b2eda53
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
16 deletions
+25
-16
Client.scala
client/src/main/scala/fr/iscpif/client/Client.scala
+11
-6
ScalaTraJSTagsWireRxBuild.scala
project/ScalaTraJSTagsWireRxBuild.scala
+4
-5
ScalatraBootstrap.scala
server/src/main/scala/ScalatraBootstrap.scala
+1
-1
Server.scala
server/src/main/scala/fr/iscpif/app/Server.scala
+9
-4
No files found.
client/src/main/scala/fr/iscpif/client/Client.scala
View file @
f88c6982
...
...
@@ -29,7 +29,7 @@ object Client {
val
submitButton1
=
button
(
"Click me"
)(
cursor
:=
"pointer"
,
onclick
:=
{
()
=>
Post
(
_
.
hello
(
5
)
).
foreach
{
i
=>
Post
[
Api
].
hello
(
5
).
call
(
).
foreach
{
i
=>
helloValue
()
=
helloValue
()
+
i
}
}
...
...
@@ -38,17 +38,18 @@ object Client {
val
submitButton2
=
button
(
"Click me"
)(
cursor
:=
"pointer"
,
onclick
:=
{
()
=>
Post
(
_
.
caseClass
).
foreach
{
s
=>
Post
[
Api
].
caseClass
.
call
(
).
foreach
{
s
=>
caseClassValue
()
=
s
.
hello
}
false
}
).
render
dom
.
document
.
body
.
appendChild
(
submitButton1
)
dom
.
document
.
body
.
appendChild
(
submitButton2
)
dom
.
document
.
body
.
appendChild
(
submitButton1
)
dom
.
document
.
body
.
appendChild
(
submitButton2
)
Rx
{
println
(
"RX "
+
helloValue
)
dom
.
document
.
body
.
appendChild
(
h1
(
helloValue
).
render
)
dom
.
document
.
body
.
appendChild
(
h1
(
caseClassValue
).
render
)
}
...
...
@@ -56,9 +57,9 @@ object Client {
}
object
Post
extends
autowire
.
Client
[
Api
]
{
object
Post
extends
autowire
.
Client
[
String
,
upickle.Reader
,
upickle.Writer
]
{
override
def
callRequest
(
req
:
Request
)
:
Future
[
String
]
=
{
override
def
doCall
(
req
:
Request
)
:
Future
[
String
]
=
{
val
url
=
req
.
path
.
mkString
(
"/"
)
dom
.
extensions
.
Ajax
.
post
(
url
=
"http://localhost:8080/"
+
url
,
...
...
@@ -67,4 +68,8 @@ object Post extends autowire.Client[Api] {
_
.
responseText
}
}
def
read
[
Result:
upickle.Reader
](
p
:
String
)
=
upickle
.
read
[
Result
](
p
)
def
write
[
Result:
upickle.Writer
](
r
:
Result
)
=
upickle
.
write
(
r
)
}
project/ScalaTraJSTagsWireRxBuild.scala
View file @
f88c6982
...
...
@@ -28,8 +28,8 @@ object ScalaTraJSTagsWireRxBuild extends Build {
scalaVersion
:=
ScalaVersion
,
resolvers
++=
Resolvers
,
libraryDependencies
++=
Seq
(
"com.lihaoyi"
%%%
"autowire"
%
"0.
1.4
"
,
"com.lihaoyi"
%%%
"upickle"
%
"0.2.
1
"
,
"com.lihaoyi"
%%%
"autowire"
%
"0.
2.2
"
,
"com.lihaoyi"
%%%
"upickle"
%
"0.2.
2
"
,
"com.scalatags"
%%%
"scalatags"
%
"0.4.0"
,
"com.scalarx"
%%%
"scalarx"
%
"0.2.6"
,
"org.scala-lang.modules.scalajs"
%%%
"scalajs-dom"
%
"0.6"
,
...
...
@@ -50,10 +50,9 @@ object ScalaTraJSTagsWireRxBuild extends Build {
scalaVersion
:=
ScalaVersion
,
resolvers
++=
Resolvers
,
libraryDependencies
++=
Seq
(
"com.lihaoyi"
%%
"autowire"
%
"0.
1.4
"
,
"com.lihaoyi"
%%
%
"upickle"
%
"0.2.1"
,
"com.lihaoyi"
%%
"autowire"
%
"0.
2.1
"
,
"com.lihaoyi"
%%
"upickle"
%
"0.2.1"
,
"com.scalatags"
%%%
"scalatags"
%
"0.4.0"
,
"org.scala-lang.modules.scalajs"
%%%
"scalajs-dom"
%
"0.6"
,
"org.scalatra"
%%
"scalatra"
%
ScalatraVersion
,
"org.scalatra"
%%
"scalatra-specs2"
%
ScalatraVersion
%
"test"
,
"ch.qos.logback"
%
"logback-classic"
%
"1.0.12"
%
"runtime"
,
...
...
server/src/main/scala/ScalatraBootstrap.scala
View file @
f88c6982
...
...
@@ -9,6 +9,6 @@ class ScalatraBootstrap extends LifeCycle {
//val serv = new MyScalatraServlet
// pluginROutes.foreach{serv.addRoute}
context
.
mount
(
new
MyScalatraServlet
,
"/*"
)
context
.
mount
(
new
Server
,
"/*"
)
}
}
server/src/main/scala/fr/iscpif/app/
MyScalatraServlet
.scala
→
server/src/main/scala/fr/iscpif/app/
Server
.scala
View file @
f88c6982
...
...
@@ -13,13 +13,18 @@ import scala.concurrent.Await
import
scalatags.Text.all._
import
scalatags.Text.
{
all
=>
tags
}
object
Server
extends
Api
{
object
AutowireServer
extends
autowire
.
Server
[
String
,
upickle.Reader
,
upickle.Writer
]{
def
read
[
Result:
upickle.Reader
](
p
:
String
)
=
upickle
.
read
[
Result
](
p
)
def
write
[
Result:
upickle.Writer
](
r
:
Result
)
=
upickle
.
write
(
r
)
}
object
ApiImpl
extends
Api
{
def
hello
(
a
:
Int
)
=
a
*
3
def
caseClass
=
MyCaseClass
(
"Hello !"
)
}
class
MyScalatraServlet
extends
ScalatraServlet
{
class
Server
extends
ScalatraServlet
{
val
basePath
=
"shared"
...
...
@@ -37,8 +42,8 @@ class MyScalatraServlet extends ScalatraServlet {
}
post
(
s
"/$basePath/*"
)
{
Await
.
result
(
autowire
.
Macros
.
route
[
Api
](
Server
)(
autowire
.
Request
(
Seq
(
basePath
)
++
multiParams
(
"splat"
).
head
.
split
(
"/"
),
Await
.
result
(
AutowireServer
.
route
[
Api
](
ApiImpl
)(
autowire
.
Core
.
Request
(
Seq
(
basePath
)
++
multiParams
(
"splat"
).
head
.
split
(
"/"
),
upickle
.
read
[
Map
[
String
,
String
]](
request
.
body
))
),
Duration
.
Inf
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment