Skip to content

Latest commit

 

History

91 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

web.boost

introduction

sample configuration file (www.cfg)

thread_count = 2
port_http = 80
port_https = 443
listen_address = 0.0.0.0
content_directory = web/content
static_host = static.example.com
static_directory = web/static
static_extension = jpg
static_extension = jpeg
static_extension = png
static_extension = css
static_extension = txt
static_extension = ico
static_extension = gif
certificate_path_fullchain = certs/fullchain.pem
certificate_path_privkey = certs/privkey.pem

build outline

  • compile environment: C++20
  • requires libssl-dev, libboost-dev (json, log, program_options, serialization, url)
  • add luajit, sol2 and fmt

build lua modules: luajit, sol2

# acquire, build & install luajit
git clone --depth=1 https://github.com/LuaJIT/LuaJIT.git
pushd LuaJIT
sed -i 's/#XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT/XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT/' src/Makefile
make
sudo make install
popd

# acquire & install sol2 (lua helpers for c++)
git clone --depth=1 https://github.com/ThePhD/sol2.git
sudo mv -n sol2/include/sol /usr/local/include/

build fmt

git clone --depth=1 https://github.com/fmtlib/fmt.git
pushd fmt
mkdir build
cd build
cmake -D FMT_TEST=FALSE ..
make
sudo make install
popd

build project

git clone --depth=1 https://github.com/rburkholder/boost.web.git
pushd boost.web
mkdir build
cd build
cmake ..
make
popd

security, run

To run on a port under 1024, requires something like:

sudo setcap CAP_NET_BIND_SERVICE=+eip ~/projects/web.boost/build/src/boost.web
~/projects/web.boost/build/src/boost.web

current features

  • 2026/08/09
  • 2026/08/02
    • GET static html and support files from a directory
    • supports HTTP and HTTPS

sample test page (test.lua)

  • influenced by riki's demo code
  • copy src/lua/html.lua to web/lib
  • create test.lua in web/content
    package.path="web/lib/?.lua"
    
    local h = require( 'html' )
    
    local output = h.Document{
      lang = "en",
    
      h.head{
        h.meta{charset = "UTF-8"},
        h.title{"Hello, world!"},
      },
    
      h.body{
        h.h1{"Hello, world!"},
        h.p{
          "This is an example of the little HTML templating framework."
        },
        h.p{
          "As you can see, it is fully capable of generating any kind of markup ",
          "you'd ever want.", h.br(),
          "It can even do things like ", h.b"bold text", "!"
        },
        h.p"This is some embedded HTML <p></p>"
      }
    }
    Render( 'text/html', tostring( output ) )

reference

alternatives

  • wt web toolkit - designed for single page applications with total control over page generation - not recommeded for internet centric applications - no lua
  • drogon web framework - excellent functionality but comes up short on SSL capability and reliability - proprietary web template, no lua
  • openresty - Web Platform Based on Nginx and LuaJIT - may come back to this
  • luvit - Asynchronous I/O for Lua

About

SSL capable Web Server running Boost Beast executing Lua scripts with LuaJit to serve web pages

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages