Skip to content

Instantly share code, notes, and snippets.

@belohlavek
Last active December 4, 2017 23:02
Show Gist options
  • Save belohlavek/ec488b96435893ea2b0a671f9f0d8daf to your computer and use it in GitHub Desktop.
Save belohlavek/ec488b96435893ea2b0a671f9f0d8daf to your computer and use it in GitHub Desktop.
Testo
{
"message": "Hello world!"
}
fun render(request) = {
html: {
body: {
(Header::render(request.queryParams.name default 'User'))
}
}
}
fun render(name: String) = {
h1 @(style: 'color: red'): "Hello $(name)"
}
%dw 2.0
fun toJSON(a) = a
import * from dw::http::Server
fun renderHtml(x) = write(x, 'text/xml', {writeDeclaration: false})
---
api({
host: "0.0.0.0",
port: 8080
}, {
"/": {
GET: (request) -> {
body: renderHtml(App::render(request)),
headers: {
'Content-Type': 'text/html'
}
}
},
"/test": {
GET: (req) -> body: req,
POST: (req) -> body: req
}
})
%dw 2.0
output application/json
---
{}
{
"project": {
"name": "Testo",
"mainScript": "scripts/main.dwl",
"apiled": {
"deploymentId": "17bb9236-670c-4cec-93e8-4f83fafdf42f",
"domain": "testo"
}
},
"meta": {
"projectFileVersion": "0.1.0",
"creationDate": "12/04/2017"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment