1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2014 Alexis Laferrière <alexis.laf@xymus.net>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # The nitcorn Web server framework creates server-side Web apps in Nit
19 # The main classes are:
20 # * `Action` to answer to requests.
21 # * `Route` to represent a path to an action.
22 # * `VirtualHost` to listen on a specific interface and behave accordingly
23 # * `HttpFactory` which is the base dispatcher class.
25 # Basic usage example:
30 # redef fun answer(http_request, turi)
32 # var response = new HttpResponse(200)
36 # <meta charset="utf-8">
37 # <title>Hello World</title>
47 # # Listen to port 8080 on all interfaces
48 # var vh = new VirtualHost("0.0.0.0:8080")
50 # # Serve index.html with our custom handler
51 # vh.routes.add new Route("/index.html", new MyAction)
53 # # Serve everything else with a standard `FileServer`
54 # vh.routes.add new Route(null, new FileServer("/var/www/"))
56 # var factory = new HttpFactory.and_libevent
57 # factory.config.virtual_hosts.add vh