GithubHelp home page GithubHelp logo

bachp / expresscpp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from expresscpp/expresscpp

0.0 1.0 0.0 716 KB

Fast, unopinionated, minimalist web framework for C++ Perfect for building REST APIs

Home Page: https://gitlab.com/expresscpp/expresscpp

License: MIT License

Shell 2.44% JavaScript 1.51% C++ 73.19% Python 0.96% CMake 20.82% Batchfile 0.06% Dockerfile 1.02%

expresscpp's Introduction

ExpressCpp

Fast, unopinionated, minimalist web framework for C++ Perfect for building REST APIs

Logo of ExpressCpp

Conan pipeline status expresscpp_http License: MIT c++17

Design goals

ExpressCpp aims to be for C++ the same as express for Node.JS including its ecosystem of middlewares and extensions.

Express and Node.JS:

const express = require('express');
const app = express();
app.get('/', (req, res) => res.send('Hello World!'));
const port = 3000;
app.listen(port, () => console.log(`Listening on port ${port}!`));

ExpressCpp:

#include "expresscpp/expresscpp.hpp"
int main() {
  auto expresscpp = std::make_shared<expresscpp::ExpressCpp>();
  expresscpp->Get("/", [](auto /*req*/, auto res) { res->Send("hello world!"); });
  constexpr uint16_t port = 3000u;
  expresscpp->Listen(port,[=](auto /*ec*/) { std::cout << "Listening on port " << port << std::endl; }).Run();
  return 0;
}

Using me

conan

conan remote add expresscpp https://api.bintray.com/conan/expresscpp/expresscpp/

add this to you conan file:

expresscpp/0.11.0@expresscpp/testing

this to your cmake:

find_package(expresscpp)
# ...
target_link_libraries(my_target PRIVATE expresscpp::expresscpp)

vendoring as subdirectory

add_subdirectory(thirdparty/expresscpp)
# ...
target_link_libraries(my_target PRIVATE expresscpp::expresscpp)

installing and using find_package

git clone https://gitlab.com/expresscpp/expresscpp.git
cd expresscpp
mkdir build
cd build
cmake ..
make -j
sudo make install

find_package(expresscpp)
# ...
target_link_libraries(my_target PRIVATE expresscpp::expresscpp)

Build instructions (e.g. ubuntu)

Dependencies

  • boost[asio, beast, uuid]
  • nlohmann/json
  • libfmt
  • gtest (optional)

Conan

sudo apt install -y cmake gcc-9 g++-9 python3-pip

# conan for dependency management
sudo pip3 install conan --upgrade

mkdir -p build
cd build
cmake .. -DEXPRESSCPP_USE_CONAN_DEPENDENCIES=ON
cmake --build . -j

Debian

sudo apt install -y cmake gcc-9 g++-9

# get debian dependencies
sudo apt install -y libboost-all-dev nlohmann-json3-dev libfmt-dev libgtest-dev

mkdir -p build
cd build
cmake ..
cmake --build . -j

Features/Examples

name file
url query params ./example/query_params.cpp
url params ./example/url_params.cpp
auth-like middleware ./example/middleware_auth_like.cpp
log-like middleware ./example/middleware_logger_like.cpp
error handler ./example/error_handler.cpp
variadic middlewares ./example/multiple_handlers.cpp
subrouting ./example/router.cpp

Official Middlewares

name file
static file provider ./example/serve_static.cpp
favicon provider(embedded) ./example/favicon.cpp
  • expresscpp-logger -> TODO
  • expresscpp-grpc-proxy -> TODO
  • expresscpp-reverse-proxy -> TODO
  • expresscpp-basic-auth -> TODO

Similiar projects

name repo
BeastHttp https://github.com/0xdead4ead/BeastHttp/
crow (unmaintained) https://github.com/ipkn/crow
Simple-Web-Server https://gitlab.com/eidheim/Simple-Web-Server
restinio https://github.com/stiffstream/restinio
served https://github.com/meltwater/served

expresscpp's People

Contributors

dependabot[bot] avatar gocarlos avatar kassane avatar tbeu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.