cnp/0.4 contnet.org/util/cn-http/ cnp/0.4 ok length=2815 modified=2021-03-04T17:26:30Z name=index.cnm time=2024-03-29T12:30:15Z type=text/cnm title util/cn-http content text fmt **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. section Installation text fmt cn-http requires @@https://golang.org/dl/ Go 1.8 or later@@. Install it with: raw sh go install contnet.org/util/cn-http@latest text fmt Or directly run it with: raw sh git clone https://git.clsr.net/contnet/cn-http cd cn-http go run cnhttp.go [OPTIONS] section Usage text fmt To use it as a gateway, run it with ``cn-http -listen HOST:PORT -cnp-host UPSTREAM``. The ``-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. The ``cn-http`` binary needs to be run in the folder containing the ``templates`` and ``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). For ``raw`` block syntax highlighting to work, the @@https://highlightjs.org/ highlight.js@@ JavaScript library needs to be available. The default paths (specified in ``templates/page.html``) are ``/static/highlight/highlight.pack.js`` for the script and ``/static/highlight/style.css`` for the stylesheet. If JavaScript-based syntax highlighting is undesirable, the ``-no-highlight`` command-line flag can be used. Gateway example: ``cd src/cn-http && cn-http -listen 0.0.0.0:80`` Browser example: ``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. section Source text fmt The cn-http source code is available on @@https://git.clsr.net/contnet/cn-http@@ links /spec/ Specifications /doc/ Documents /draft/ Drafts /lib/ Libraries /util/ Tools and utilities site tool cn-http