랭킹으로 돌아가기

pistacheio/pistache

C++pistacheio.github.io/pistache/

A high-performance REST toolkit written in C++

serverapi-rest
스타 성장
스타
3.5k
포크
712
주간 성장
이슈
201
1k2k3k
2015년 10월2019년 5월2022년 12월2026년 7월
README

Pistache

N|Solid

linux autopkgtest codecov REUSE status

Pistache is a modern and elegant HTTP and REST framework for C++. It is entirely written in pure-C++17* and provides a clear and pleasant API.

Pistache supports Linux, macOS, Windows and BSD (FreeBSD, OpenBSD, and NetBSD). To use in macOS, Windows, or BSD, see the respective files: Building on macOS.txt, Building on Windows.txt or Building on BSD.txt.

Documentation

We are still looking for a volunteer to document fully the API. In the mean time, partial documentation is available at pistacheio.github.io/pistache/. If you are interested in helping with this, please open an issue ticket.

A benchmark comparison of Pistache to other C++ RESTful APIs was created by guteksan and is available here.

Articles, Tutorials & Videos

Dependencies

Pistache has the following third party dependencies

Contributing

Pistache is released under the Apache License 2.0. Contributors are welcome!

Pistache was originally created by Mathieu Stefani (@octal). He continues to contribute to the maintainence and development of Pistache, supported by a team of volunteers. The maintainers can be reached in #pistache on Libera.Chat (ircs://irc.libera.chat:6697). Please come and join us!

The Launchpad Team administers the daily and stable Ubuntu pre-compiled packages.

Versioning

The version of the library's public interface (ABI) is not the same as the release version, but we plan to always guarantee that the major release version and the soname version will match after the 1.0 release; until that, the soname version will follow feature releases. The interface version is primarily associated with the external interface of the library. Different platforms handle this differently, such as AIX, GNU/Linux, and Solaris.

GNU Libtool abstracts each platform's idiosyncrasies away because it is more portable than using ar(1) or ranlib(1) directly. However, it is not supported in Meson so we made do without it by setting the SONAME directly.

When Pistache is installed it will normally ship:

  • libpistache.so.X.Y.Z: This is the actual shared-library binary file. The X, Y and Z values are the major, minor and patch interface versions respectively.

  • libpistache.so.X.Y: This is the soname soft link that points to the binary file. It is what other programs and other libraries reference internally. You should never need to directly reference this file in your build environment.

  • libpistache.so: This is the linker name entry. This is also a soft link that refers to the soname with the highest major interface version. This linker name is what is referred to on the linker command line.

  • libpistache.a: This is the static archive form of the library. Since when using a static library all of its symbols are normally resolved before runtime, an interface version in the filename is unnecessary.

If your contribution has modified the interface, you may need to update the major or minor interface versions. Otherwise user applications and build environments will eventually break. This is because they will attempt to link against an incorrect version of the library -- or worse, link correctly but with undefined runtime behaviour.

The major version should be incremented when you make incompatible API or ABI changes. The minor version should be incremented when you add functionality in a backwards compatible manner. The patch version should be incremented when you make backwards compatible bug fixes. This can be done by modifying version.txt accordingly. Also remember to always update the commit date in the aformentioned file.

Precompiled Packages

If you have no need to modify the Pistache source, you are strongly recommended to use precompiled packages for your distribution. This will save you time.

Debian and Ubuntu

Pistache is available in the official repositories since Debian 12 and Ubuntu 23.10, under the package name libpistache-dev.

macOS

Pistache can be installed using the Homebrew package manager. See Building on macOS.txt for specifics.

Supported Architectures

Currently Pistache is built and tested on a number of architectures. Some of these are suitable for desktop or server use and others for embedded environments. As of this writing we do not currently have any MIPS related packages that have been either built or tested.

  • amd64
  • arm64
  • armhf
  • i386
  • ppc64el
  • riscv64
  • s390x

Ubuntu PPA (Unstable)

The project builds daily unstable snapshots in a separate unstable PPA. To use it, run the following:

$ sudo add-apt-repository ppa:pistache+team/unstable
$ sudo apt update
$ sudo apt install libpistache-dev

Ubuntu PPA (Stable)

From time to time, the project transfers release packages into the stable PPA. Run the following to install a stable package:

$ sudo add-apt-repository ppa:pistache+team/stable
$ sudo apt update
$ sudo apt install libpistache-dev

Other Distributions

Package maintainers, please insert instructions for users to install pre-compiled packages from your respective repositories here.

Use via pkg-config

If you would like to automatically have your project's build environment use the appropriate compiler and linker build flags, pkg-config can greatly simplify things. It is the portable international de facto standard for determining build flags. The development packages include a pkg-config manifest.

GNU Autotools

To use with the GNU Autotools, as an example, include the following snippet in your project's configure.ac:

# Pistache...
PKG_CHECK_MODULES(
    [libpistache], [libpistache >= 0.0.2], [],
    [AC_MSG_ERROR([libpistache >= 0.0.2 missing...])])
YOURPROJECT_CXXFLAGS="$YOURPROJECT_CXXFLAGS $libpistache_CFLAGS"
YOURPROJECT_LIBS="$YOURPROJECT_LIBS $libpistache_LIBS"

Meson

To use with Meson, you just need to add dependency('libpistache') as a dependency for your executable.

project(
    'MyPistacheProject',
    'cpp',
    meson_version: '>=0.55.0'
)

executable(
    'MyPistacheExecutable',
    sources: 'main.cpp',
    dependencies: dependency('libpistache')
)

If you want to build the library from source in case the dependency is not found on the system, you can add this repository as a submodule in the subprojects directory of your project, and edit the dependency() call as follows:

dependency('libpistache', fallback: 'pistache')

If you're using a Meson version older than 0.55.0 you'll have to use the "older" syntax for dependency():

dependency('libpistache', fallback: ['pistache', 'pistache_dep'])

Lastly, if you'd like to build the fallback as a static library you can specify it with the default_options keyword:

dependency('libpistache', fallback: 'pistache', default_options: 'default_library=static')

CMake

To use with a CMake build environment, use the FindPkgConfig module. Here is an example:

cmake_minimum_required(VERSION 3.6)
project("MyPistacheProject")

find_package(PkgConfig)
pkg_check_modules(Pistache REQUIRED IMPORTED_TARGET libpistache)

add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} PkgConfig::Pistache)

Makefile

To use within a vanilla makefile, you can call pkg-config directly to supply compiler and linker flags using the shell assignment operator.

PC_CXXFLAGS != pkg-config --cflags libpistache
PC_LDFLAGS != pkg-config --libs libpistache

CXXFLAGS += $(PC_CXXFLAGS)
LDFLAGS += $(PC_LDFLAGS)

all:
	c++ -o main main.cpp $(CXXFLAGS) $(LDFLAGS)

Building from source

To download the latest available release, clone the repository over GitHub.

$ git clone https://github.com/pistacheio/pistache.git

To build on macOS, Windows, or BSD, see the respective files Building on macOS.txt, Building on Windows.txt or Building on BSD.txt.

Continuing the Linux instructions:

Now, compile the sources:

$ cd pistache
$ meson setup build                                 \
    --buildtype=release                             \
    -DPISTACHE_USE_SSL=true                         \
    -DPISTACHE_BUILD_EXAMPLES=true                  \
    -DPISTACHE_BUILD_TESTS=true                     \
    -DPISTACHE_BUILD_DOCS=false                     \
    -DPISTACHE_USE_CONTENT_ENCODING_BROTLI=true     \
    -DPISTACHE_USE_CONTENT_ENCODING_DEFLATE=true    \
    -DPISTACHE_USE_CONTENT_ENCODING_ZSTD=true    \
    --prefix="$PWD/prefix"
$ meson compile -C build
$ meson install -C build

Optionally, you can also run the tests. You can skip tests requiring network access with --no-suite=network:

$ meson test -C build

Be patient, async_test can take some time before completing. And that's it, now you can start playing with your newly installed Pistache framework.

Some other Meson options:

Option Default Description
PISTACHE_USE_SSL False Build server with SSL support
PISTACHE_BUILD_TESTS False Build all of the unit tests
PISTACHE_BUILD_EXAMPLES False Build all of the example apps
PISTACHE_BUILD_DOCS False Build Doxygen docs
PISTACHE_USE_CONTENT_ENCODING_BROTLI False Build with Brotli content encoding support
PISTACHE_USE_CONTENT_ENCODING_DEFLATE False Build with deflate content encoding support
PISTACHE_USE_CONTENT_ENCODING_ZSTD False Build with zstd content encoding support

Example

Hello World (server)

#include <pistache/endpoint.h>

using namespace Pistache;

struct HelloHandler : public Http::Handler {
  HTTP_PROTOTYPE(HelloHandler)
  void onRequest(const Http::Request&, Http::ResponseWriter writer) override {
    writer.send(Http::Code::Ok, "Hello, World!");
  }
};

int main() {
  Http::listenAndServe<HelloHandler>(Pistache::Address("*:9080"));
}

Tutorials

Project status

Pistache hasn't yet hit the 1.0 release. This means that the project is unstable but not unusable. In fact, most of the code is production ready; you can use Pistache to develop a RESTful API without issues, but the HTTP client has a few issues in it that make it buggy.

* While most code uses modern C++, Pistache makes use of some platform-specific APIs where the standard library doesn't provide alternatives. If you know how to help, please contribute a PR to add support for your desired platform :)

관련 저장소
gin-gonic/gin

Gin is a high-performance HTTP web framework written in Go. It provides a Martini-like API but with significantly better performance—up to 40 times faster—thanks to httprouter. Gin is designed for building REST APIs, web applications, and microservices.

GoGo ModulesMIT Licenseservermiddleware
gin-gonic.com
88.9k8.7k
expressjs/express

Fast, unopinionated, minimalist web framework for node.

JavaScriptnpmMIT Licensejavascriptnodejs
expressjs.com
69.2k24.3k
withastro/astro

The web framework for content-driven websites. ⭐️ Star to support our work!

TypeScriptnpmOtherstatic-site-generatorblog
astro.build
61.2k3.6k
coollabsio/coolify

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 280+ one-click services on your own servers.

PHPPackagistApache License 2.0nodejsmysql
coolify.io
59.2k5.1k
imthenachoman/How-To-Secure-A-Linux-Server

An evolving how-to guide for securing a Linux server.

Creative Commons Attribution Share Alike 4.0 Internationallinuxhardening
29.5k2k
PostgREST/postgrest

REST API for any Postgres database

HaskellMIT Licensehaskelldatabase
postgrest.org
27.5k1.2k
vapor/vapor

💧 A server-side Swift HTTP web framework.

SwiftMIT Licensevaporswift
vapor.codes
26.2k1.5k
valeriansaliou/sonic

🦔 Fast, lightweight & schema-less search backend. An alternative to Elasticsearch that runs on a few MBs of RAM.

Rustcrates.ioMozilla Public License 2.0rustinfrastructure
crates.io/crates/sonic-server
21.3k615
gofr-dev/gofr

An opinionated GoLang framework for accelerated microservice development. Built in support for databases and observability.

GoGo ModulesApache License 2.0gogolang
gofr.dev
21.1k1.8k
elysiajs/elysia

Ergonomic Framework for Humans

TypeScriptnpmMIT Licenseframeworktypescript
elysiajs.com
18.7k556
ory/hydra

Internet-scale OpenID Certified™ OpenID Connect and OAuth2.1 provider that integrates with your user management through headless APIs. Solve OIDC/OAuth2 user cases over night. Consume as a service on Ory Network or self-host. Trusted by OpenAI and many others for scale and security. Written in Go.

GoGo ModulesApache License 2.0hydraoauth2
ory.com
17.4k1.6k
Grasscutters/Grasscutter

A server software reimplementation for a certain anime game.

JavaMavenGNU Affero General Public License v3.0javakcp
grasscutter.io
16.8k4.3k