ronpage is a simple HTTP router, using pages defined in `page.ron` file in the running directory. It takes no commandline arguments and will auto-create a sample config file if one isn't found. The `page.ron` file looks something like this: ``` ( // Bind address and port, self-explanatory. bind: "0.0.0.0:80", // The top-level "host" router. This lets you serve completely different pages // depending on the client's `Host` header, if you have multiple DNS entries // pointing to the same address. routes: { // If the `Host` header matches any strings in this array, it will use these // pages. `None` means "default" or "fallback" and should be preferred; // leaving it undefined will return a completely empty 404 page. // Do note that exactly duplicate keys in maps `{ }` are ignored (blame serde), // but if there's 2 same routes grouped with other routes, ronpage will error. None: { // Same deal with the `Host` header, but this time matching the path. If the URL // matches any of these, it will fall back on `None` (if it exists, otherwise // a blank page). Only pages defined here will be served. // The page's content can be 1 of 3 enums. // `Hardcode` returns the `content` field as-is. Could be used for debugging or // simple messages. None: Hardcode ( // The raw content of the response. content: "Nothing here", // The content's MIME type. There's no reason to waste time guessing the type // if you know it beforehand. mime: "text/plain", // Defaults to 200 OK if undefined. code: "404 Not Found", // Defaults to empty if undefined. headers: [("Header", "Value")], ) // `File` responds with a file's entire contents, like a regular server would. ["/", "/index.html"]: File ( // The file path - doesn't have to match the URL by any means. path: "www/main.html", // See above mime: "text/html", code: "200 Probably OK", //headers: [("Set-Cookie", "session=wellthisisuseless")], // I like to gzip static pages manually and put that as the page content, // there's no point compressing the same HTML every request. Set this to `true` // and it will set a couple headers to enable decoding gzipped responses // client-side. // It assumes all browsers support this, because all browsers do support this. gzip: false, ), // `Forward` serves as a reverse-proxy to whatever socket address you put, copying the // entire HTTP packet exactly as-is, header and all. Useful for adding some logic behind // ronpage by running a separate server that does all the actual work. // Don't set the `addr` to ronpage's bind address, it will create an infinite loop and // crash. ["/proxy"]: Forward("192.168.69.42:80"), }, // Example of a host match. Besides an empty 404 response, no other data will be served, // even if it matches URLs under other hosts. ["192.168.0.2", "192.168.0.2:80"]: { ["/"]: Hardcode ( content: "You will only see this if you curl 192.168.0.2 (given that's your IP)", mime: "text/plain", ), }, }, ) ```