All Projects → zussel → matador

zussel / matador

Licence: GPL-3.0 license
Take your appclication by the horns

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to matador

Fs2 Http
Http Server and client using fs2
Stars: ✭ 132 (+123.73%)
Mutual labels:  http-client, http-server
Libhv
🔥 比libevent、libuv更易用的国产网络库。A c/c++ network library for developing TCP/UDP/SSL/HTTP/WebSocket client/server.
Stars: ✭ 3,355 (+5586.44%)
Mutual labels:  http-client, http-server
Http4k
The Functional toolkit for Kotlin HTTP applications. http4k provides a simple and uniform way to serve, consume, and test HTTP services.
Stars: ✭ 1,883 (+3091.53%)
Mutual labels:  http-client, http-server
Akka Http
The Streaming-first HTTP server/module of Akka
Stars: ✭ 1,163 (+1871.19%)
Mutual labels:  http-client, http-server
Donkey
Modern Clojure HTTP server and client built for ease of use and performance
Stars: ✭ 199 (+237.29%)
Mutual labels:  http-client, http-server
Zio Tls Http
100% non-blocking, Java NIO only( inspired by zio-nio) , JSON HTTP server based on Scala ZIO library. Everything including TLS encryption modeled as ZIO effects, convenient route DSL similar to https4s, up to 30K TPS local JSON transaction with 25 threads on 6 cores(i7) with ZIO fibers.
Stars: ✭ 71 (+20.34%)
Mutual labels:  http-client, http-server
Httpp
Micro http server and client written in C++
Stars: ✭ 144 (+144.07%)
Mutual labels:  http-client, http-server
Cxxhttp
Asynchronous, Header-only C++ HTTP-over-(TCP|UNIX Socket|STDIO) Library
Stars: ✭ 24 (-59.32%)
Mutual labels:  http-client, http-server
Http Kit
http-kit is a minimalist, event-driven, high-performance Clojure HTTP server/client library with WebSocket and asynchronous support
Stars: ✭ 2,234 (+3686.44%)
Mutual labels:  http-client, http-server
Zio Http
A scala library to write Http apps.
Stars: ✭ 162 (+174.58%)
Mutual labels:  http-client, http-server
Flogo Contrib
Flogo Contribution repo. Contains activities, triggers, models and actions.
Stars: ✭ 60 (+1.69%)
Mutual labels:  http-client, http-server
EthernetWebServer SSL
Simple TLS/SSL Ethernet WebServer, HTTP Client and WebSocket Client library for for AVR, Portenta_H7, Teensy, SAM DUE, SAMD21, SAMD51, STM32F/L/H/G/WB/MP1, nRF52 and RASPBERRY_PI_PICO boards using Ethernet shields W5100, W5200, W5500, ENC28J60 or Teensy 4.1 NativeEthernet/QNEthernet. It now supports Ethernet TLS/SSL Client. The library supports …
Stars: ✭ 40 (-32.2%)
Mutual labels:  http-client, http-server
Foxy
Session-based Beast/Asio wrapper requiring C++14
Stars: ✭ 57 (-3.39%)
Mutual labels:  http-client, http-server
Qtnetworkng
QtNetwork Next Generation. A coroutine based network framework for Qt/C++, with more simpler API than boost::asio.
Stars: ✭ 125 (+111.86%)
Mutual labels:  http-client, http-server
Jiny
Lightweight, modern, simple JVM web framework for rapid development in the API era
Stars: ✭ 40 (-32.2%)
Mutual labels:  http-client, http-server
Aiohttp
Asynchronous HTTP client/server framework for asyncio and Python
Stars: ✭ 11,972 (+20191.53%)
Mutual labels:  http-client, http-server
Poco
The POCO C++ Libraries are powerful cross-platform C++ libraries for building network- and internet-based applications that run on desktop, server, mobile, IoT, and embedded systems.
Stars: ✭ 5,762 (+9666.1%)
Mutual labels:  http-client, http-server
Sylar
C++高性能分布式服务器框架,webserver,websocket server,自定义tcp_server(包含日志模块,配置模块,线程模块,协程模块,协程调度模块,io协程调度模块,hook模块,socket模块,bytearray序列化,http模块,TcpServer模块,Websocket模块,Https模块等, Smtp邮件模块, MySQL, SQLite3, ORM,Redis,Zookeeper)
Stars: ✭ 895 (+1416.95%)
Mutual labels:  http-client, http-server
Http4s
A minimal, idiomatic Scala interface for HTTP
Stars: ✭ 2,173 (+3583.05%)
Mutual labels:  http-client, http-server
cpphttpstack
c++ api for http client & server
Stars: ✭ 30 (-49.15%)
Mutual labels:  http-client, http-server

matador

Take your database by the horns.

Version 0.8.1 GPLv3 C++14

Build Status

Branches Linux-CI Windows-CI CodeCov
master Build Status Build status codecov
develop Build Status Build status codecov

matador is an ORM and Web Application framework written in C++. It encapsulates all database backend communication and offers a simple (web) server. You don't have to deal with database backends or sql statements neither with mapping of data types nor serialization of objects. It comes with relation handling out of the box, brings a unique container for all kind of objects and a fluent sql query interface. All features are combined into an ORM layer. With the integrated web server it is possible to write your own web application with database backend.

Features:

  • A unique fluent query interface
  • One to one/many relations
  • One storage container
  • Filter with simple expressions
  • Transactions
  • STL like interface and iterators
  • Json support including parser and object mapper
  • Simple Logging mechanism
  • Networking
  • Web Server
  • Template Engine

Supported databases:

  • PostgreSQL
  • SQLite
  • MySQL
  • MS SQL Server

Documentation can be found here.

Example

The following example define an entity person, sets up orm backend and logging and creates a http server listening at port 8000. The server serves five REST apis at http://localhost:8000/person/:

  • GET / (returns all person)
  • GET /{id} (return person with id where id must be numeric)
  • POST / (creates a person from the given json body)
  • PUT /{id} (updates a person with id from the given json body)
  • DELETE /{id} (deletes a person with id)
// use matador namespace
using namespace matador

// a simple person class
struct person
{
  identifier<long> id;   // primary key
  std::string name;
  date birthday;
  has_many<std::string> colors;
  
  person() = default;
  person(long i, std::string n)
    : id(i), name(std::move(n))
  {}
  
  template < class SERIALIZER >
  void serialize(SERIALIZER &serializer) {
    serializer.serialize("id", id);
    serializer.serialize("name", name, 255);
    serializer.serialize("birthday", birthday);
    serializer.serialize("person_color",  // relation table name
                         colors,          // class member
                         "person_id",     // left column in relation table
                         "color",         // right column in relation table
                         matador::cascade_type::ALL); // cascade type
  }
};

// setup application logging
add_log_sink(matador::create_file_sink("log/server.log"));
add_log_sink(matador::create_stdout_sink());

// prepare the persistence layer
persistence p("sqlite://db.sqlite");
p.enable_log();
p.attach<person>("person");

// create tables
p.create();

// create a database session and
// load data from db
session s(p);
s.load();

// initialize network stack
net::init();

// create server and add routing
http::server server(8000);
server.add_routing_middleware();

// return all persons
server.on_get("/person", [&s](const request &req) {
  auto result = s.select<person>();
  json_object_mapper mapper;

  std::string body = mapper.to_string(result, json_format::pretty);

  return response::ok(body, mime_types::TYPE_APPLICATION_JSON);
});

// return one person
server.on_get("/person/{id: \\d+}", [&s](const http::request &req) {
  auto id = std::stoul(req.path_params().at("id"));
  auto result = s.get<person>(id);

  if (result.empty()) {
    return http::response::not_found();
  }

  json_object_mapper mapper;

  std::string body = mapper.to_string(result, json_format::pretty);

  return http::response::ok(body, http::mime_types::TYPE_APPLICATION_JSON);
});

// insert person
server.on_post("/person", [&s](const http::request &req) {
  json_object_mapper mapper;

  auto p = mapper.to_ptr<person>(req.body());
  auto optr = s.insert(p.release());
  s.flush();

  std::string body = mapper.to_string(optr, json_format::pretty);
  return http::response::ok(body, http::mime_types::TYPE_APPLICATION_JSON);
});

// update person
server.on_put("/person/{id: \\d+}", [&s](const http::request &req) {
  auto id = std::stoul(req.path_params().at("id"));
  auto result = s.get<person>(id);

  if (result.empty()) {
    return http::response::not_found();
  }

  json_object_mapper mapper;
  auto p = mapper.to_ptr<person>(req.body());

  // update entity
  result.modify()->name = p->name;
  result.modify()->birthday = p->birthday;
  result.modify()->colors.clear();
  for (const auto &color : p->colors) {
    result.modify()->colors.push_back(color);
  }
  s.flush();

  return http::response::no_content();
});

// delete person
server.on_remove("/person/{id: \\d+}", [&s](const http::request &req) {
  auto id = std::stoul(req.path_params().at("id"));
  auto result = s.get<person>(id);

  if (result.empty()) {
   return http::response::not_found();
  }

  s.remove(result);

  return http::response::no_content();
});

server.run();
net::cleanup();

Requirements

The library has almost no dependencies. At least the database library you want to use. If you would like to build from the sources you need at least the cmake build system installed. If you plan to generate an install package on a windows system you need the nullsoft scriptable install system.

Sources

Get the sources from GitHub and enter the created directory:

$ git clone https://github.com/zussel/matador.git
$ cd matador

Building under Linux

Create a build directory change to it and call cmake:

$ mkdir build
$ cd build
$ cmake ..

Then you can build matador from sources:

$ make

Building under Windows (for Visual Studio)

Create a build directory change to it and call cmake:

$ mkdir build
$ cd build
$ cmake -G "Visual Studio *" ..

Where * is one of the "Visual Studio" strings up from "14". See cmake documentation here. After generation you find a matador.sln solution file in the current directory.

Contact

If you have questions or issues concerning matador you can place an issue in my matador github repository

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].