cn-http is a CNP-to-HTTP translating gateway that can also act as a ContNet browser.
It listens on HTTP, translating incoming requests into CNP and forwarding them to the specified CNP server. The response is then converted into HTTP and, if it contained a
text/cnm document, the document is converted into HTML.
It supports all current CNP 0.3 features except requests with data.
modified cache parameters are fully functional and translate to the corresponding
If-Modified HTTP headers. It supports CNP 0.4
cnm: selectors with the
?select= GET parameter, but lacks proper support for using them. CNM section selectors are supported as page anchors.
cn-http requires Go 1.8 or later.
Install it with:
go install contnet.org/util/cn-http@latest
Or directly run it with:
git clone https://git.clsr.net/contnet/cn-http cd cn-http go run cnhttp.go [OPTIONS]
To use it as a gateway, run it with
cn-http -listen HOST:PORT -cnp-host UPSTREAM.
-listen parameter defaults to
localhost:8080. If the
-cnp-host parameter is not specified, cn-http runs in browser mode, where it prepends the hostname to every path and provides a URL input box on top of the page, which allows requesting CNP pages from arbitrary hosts.
cn-http binary needs to be run in the folder containing the
static folders found in its source code repository.
By default, cn-http serves requests under the path
/static/ from the local
./static/ folder. This can be disabled with the flag
-no-static, in which case any static files should be provided via the CNP upstream server (this will also break browser mode and shouldn't be used there).
/static/highlight/highlight.pack.js for the script and
-no-highlight command-line flag can be used.
cd src/cn-http && cn-http -listen 0.0.0.0:80
cd src/cn-http && cn-http, then open http://localhost:8080 in a web browser
A sample systemd service unit file is also provided with the source code.
The cn-http source code is available on https://git.clsr.net/contnet/cn-http