|
// retoor <retoor@molodetz.nl>
|
|
|
|
import "web" for Response
|
|
|
|
var r1 = Response.text("Hello")
|
|
System.print(r1.body) // expect: Hello
|
|
System.print(r1.headers["Content-Type"].contains("text/plain")) // expect: true
|
|
|
|
var r2 = Response.html("<h1>Hi</h1>")
|
|
System.print(r2.body) // expect: <h1>Hi</h1>
|
|
System.print(r2.headers["Content-Type"].contains("text/html")) // expect: true
|
|
|
|
var r3 = Response.json({"name": "test"})
|
|
System.print(r3.body.contains("name")) // expect: true
|
|
System.print(r3.headers["Content-Type"].contains("application/json")) // expect: true
|
|
|
|
var r4 = Response.redirect("/login")
|
|
System.print(r4.status) // expect: 302
|
|
System.print(r4.headers["Location"]) // expect: /login
|