11WIP: Implementing the webstack in Julia.
22
3- Simple HTTP hello world:
3+ ## Dependencies
4+
5+ * Julia, since it's that's what it's all written in.
6+
7+ ##Simple HTTP hello world:
8+
9+ If you want to handle things at the level of just
10+ HTTP requests and responses, this is a simple example
11+ of returning "Hello <name >!" only on "/hello/<name >" paths,
12+ and a 404 on all others.
13+
14+ Put it in a file called ` http.jl ` and then use the command ` julia http.jl ` to run it.
15+ If you open ` localhost:8000/hello/user ` , you'll get to see the server say hello.
416
517``` .jl
618using Http
@@ -16,7 +28,19 @@ server = Server( http )
1628run ( server, 8000 )
1729```
1830
19- Middleware using ` Meddle ` :
31+ ##Middleware using ` Meddle ` :
32+
33+ This is an example of using our middleware framework, Meddle.
34+ It puts each request through a "stack" of handlers,
35+ each of which can modify the request and/or response objects.
36+
37+ This particular example is a file server.
38+ It will serve files from the directory you run it in,
39+ and respond with ` 404 ` s if you give an invalid path.
40+
41+ Put it in a file called ` meddle.jl ` and then use the command ` julia meddle.jl ` to run it.
42+ If you run it from inside your ` webstack.jl ` folder,
43+ you could then open ` localhost:8000/examples/meddle.jl ` to have it serve its own code to you.
2044
2145``` .jl
2246using Http
@@ -37,4 +61,4 @@ run( server, 8000 )
3761
3862[ Never graduate] [ HS ] .
3963
40- [ HS ] : https://www.hackerschool.com
64+ [ HS ] : https://www.hackerschool.com
0 commit comments