From 01e16cb0e5a671880b1080d222f79b14e7d597d6 Mon Sep 17 00:00:00 2001 From: Louis Capitanchik <contact@louiscap.co> Date: Tue, 19 Jun 2018 16:18:06 +0100 Subject: [PATCH] Enhance Example --- example/.swerve/get_user.lua | 16 ++++++++++++---- example/index.html | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/example/.swerve/get_user.lua b/example/.swerve/get_user.lua index fd91f9f..b3d66f0 100644 --- a/example/.swerve/get_user.lua +++ b/example/.swerve/get_user.lua @@ -3,10 +3,18 @@ print("We're going to the races"); foo = 1 + 1; r = empty_response(); -r:set_status(404); --- r:set_header("foo", "bar"); --- r:set_body() +r:set_status(200); +r:set_header("X-Powered-By", "Swerve"); +r:set_header("Content-Type", "text/plain"); +r:set_body("This is my only response"); -return response(200, "application/json", json_encode({ foo = 123 })); +--return r + +r = response(200, "application/json", json_encode({ foo = 123 })); + +r:unset_body(); +r:set_status(204); + +return r -- return response(200, "application/json", '{ "foo": ' .. foo .. ' }') \ No newline at end of file diff --git a/example/index.html b/example/index.html index 080c0fc..17d3d1e 100644 --- a/example/index.html +++ b/example/index.html @@ -8,6 +8,7 @@ <body> <h1>It's Swervin' Time</h1> <p>This page is part of the swerve example, and includes a stylesheet and stuff.</p> + <img src="/files/adorable-puppy.jpg"> <script async src="js/say_hello.js"></script> </body> </html> \ No newline at end of file -- GitLab