rikitiki  v0.1.67
Build C++ web server modules that allow easy routing and deployment.
rikitiki::examples::RestModule Struct Reference

#include <rest.h>

Public Member Functions

void throwNQ (ConnContext &ctx, int retval, int desired_retval)
 Throw an exception if a sqlite operation returns an unexpected return value.
 
Json::Value readRow (sqlite3_stmt *stmt)
 Read a single row from a result set.
 
void POST (ConnContext &ctx)
 Post operations add items to the DB.
 
void GET (ConnContext &ctx)
 Get operations without an ID return a list of all books.
 
void GET (ConnContext &ctx, int id)
 
void DELETE (ConnContext &ctx)
 
void init_db ()
 
void Register (Server &server)
 

Public Attributes

sqlite3_stmt * insert_stmt
 
sqlite3_stmt * select_all_stmt
 
sqlite3_stmt * select_stmt
 
sqlite3 * handle
 

Static Public Attributes

static const char * create_table = "create table if not exists books (id INTEGER PRIMARY KEY, name TEXT NOT NULL, author TEXT NOT NULL, isbn TEXT NOT NULL)"
 
static const char * select_all = "select id, name, author, isbn from books;"
 
static const char * select = "select id, name, author, isbn from books where id = ?;"
 
static const char * insert = "insert into books (name, author, isbn) values (?, ?, ?)"
 

Detailed Description

Example implementation of a REST module against sqlite. Demonstrates

  • Rest Features
  • Json Features

The documentation for this struct was generated from the following file: