1 ! Copyright (C) 2011 John Benediktsson
2 ! See https://factorcode.org/license.txt for BSD license
4 USING: accessors furnace.actions http.server
5 http.server.dispatchers http.server.responses http.server.static
6 io.servers kernel namespaces ;
10 : <hello-action> ( -- action )
12 [ "Hello, world!" <text-content> ] >>display ;
14 TUPLE: benchmark-dispatcher < dispatcher ;
16 : <benchmark-dispatcher> ( -- dispatcher )
17 benchmark-dispatcher new-dispatcher
18 <hello-action> "hello" add-responder
19 "resource:" <static> "static" add-responder ;
21 : run-benchmark-webapp ( -- )
22 <benchmark-dispatcher>
23 main-responder set-global
24 8080 httpd wait-for-server ;
26 ! Use this with apachebench:
29 ! https://localhost:8080/hello
32 ! https://localhost:8080/static/readme.html
34 MAIN: run-benchmark-webapp