Mordinel / hussar

A multi-threaded web server framework
GNU General Public License v3.0
0 stars 0 forks source link

Implement database backend API #5

Open Mordinel opened 2 years ago

Mordinel commented 2 years ago

start with sqlite3 and then provide some wrapper for a common api to other DBMS's

prepared statements should be built in

Mordinel commented 2 years ago

Some kind of query api such as: hussar::DB::query("SELECT username, password FROM users WHERE username = ?", { req.post["username"] }); where the first parameter is the query with ? for prepared statement parameters, and the second parameter being a vector of strings to be sanitized by the DBMS and interpolated into the query.

ignacionr commented 2 years ago

Hmmm... so you're not really trying to offer a web server but rather some kind of do-it-all framework?

Mordinel commented 2 years ago

It is what I call a web-server framework.

The idea is to maintain some subset of HTTP that is compatible with modern web browsers, and provide programmers with an API to write server-side web applications without relying on large components such as dedicated web servers and CGI, and to do it with the performance of modern C++.

What you can see in src/main.cpp is some basic web server functionality, a request asks for a document, the server reads it from the document root directory and sends the document to the web client. This server is invoked from the command line with a number of parameters, and is currently my replacement for python3 -m http.server, super handy.

The objective for this database API is to initially allow for session persistence through a restart of the application, so that for example; login states can be resumed after a restart, and for this to be managed internally by the framework. This functionality should also be available to programmers for database programming. I believe sqlite3 is ideal for this role as the databases can be managed locally as one file per database.

This project is still young and small, which gives flexibility in its direction, but at least initially, the objective is to provide a programming API for server-side web applications programming that implements features considered "essential" or "the basics" when it comes to the web. Features such as cookies, sessions, database programming, file uploads, html templating and more.