• This repository has been archived on 12/Dec/2022
  • Stars
    star
    101
  • Rank 338,166 (Top 7 %)
  • Language
    C++
  • License
    MIT License
  • Created almost 9 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Yet another web framework—this time in modern C++!

Build Status Coverage Status badge

Luna

Full Documentation

A web application and API framework in modern C++

A web application and API framework in modern C++, Luna is designed to be easy to use and integrate with any C++ project that needs to serve HTTP endpoints. Luna’s core philosophy is that it should be easy to use correctly and difficult to use incorrectly. Of course, it should be robust as well.

You are writing in C++ (because C++ is awesome), and your app needs to provide a lightweight HTTP server to communicate with other web services. libmicrohttpd is super-awesome, except for that idiomatically C API. Luna is an idiomatically C++ wrapper for libmicrohttpd that leans on modern C++ programming concepts.

HTTP server creation, start, shut down, and deletion are all handled behind the scenes with the magic of RAII. Starting a server is automatic with instantiating a server object, and allowing your server object to fall out of scope is all that is needed to cleanly shut it down. There is nothing else for you to keep track of, or allocate.

Adding endpoints to your server is likewise meant to be simple. Nominate an endpoint with a string or regex and an HTTP verb, and pass in a lambda or other std::functional-compatible object (function pointers, bound class member functions), and return a string containing the desired response body. Of course, you can set headers and mime types, too.

Example code

But don't take my word for it. Here is some code for serving a simple JSON snippet from a single endpoint.

#include <string>
#include <luna/luna.h>

using namespace luna;

int main(void)
{
    //start a server delivering JSON by default on the default port 8080
    server server;

    // Handle GET requests to "localhost:8080/endpoint"
    // Respond with a tiny bit of fun JSON
    auto router = server.create_router("/");

    router->set_mime_type("application/json"); //the default is "text/html; charset=utf-8"

    router->handle_request(request_method::GET, "/endpoint",
                          [](auto request) -> response
    {
        return {"{\"made_it\": true}"};
    });

    server.start(); //run forever, basically, or until the server decides to kill itself.
}

Prerequisites

A C++14 capable compiler (tested against gcc 4.9, clang 3.6), CMake 2.8. Conan for installing dependencies.

License

MIT

More Repositories

1

magique

A tool that applies genetic algorithms to building Magic: The Gathering decks.
C++
40
star
2

easy-peasy-slash-command-app

Getting started with Slack slash commands
JavaScript
30
star
3

Ethical-Resources

A list of reading and resources for ethical source software.
29
star
4

engine

A modern C++ library for building modern Slack-enabled applications
C++
28
star
5

deadbolt

Objective-C
20
star
6

libmime

A C++ library for guessing MIME types from filenames
C++
11
star
7

triagebot

Ruby
7
star
8

silverstar

A standalone user registration and authentication microservice in modern C++
C++
6
star
9

TLC5941

TLC5941 is a high-level object-oriented Arduino library for driving large numbers of LEDs using the Texas Instruments TLC5941, TLC5940, and TLC59401 LED drivers. The library is broken into four main classes: The Controller class, which handles all the hardware related stuff, the TLC5941 class, which acts a proxy for each actual TLC5941 (and will be extended to cover TLC5940's shortly), the Light class, which acts as a proxy for each actual string of LEDs attached to the TLC5941's, and some examples of classes for creating special effects---a randomly flickering fire, a Larson (Cylon/KITT) scanner, and simulated traffic lights.
C++
6
star
10

algolia-link-bot

Ruby
3
star
11

conan-cpp-jwt

A Conan wrapper for cpp-jwt https://github.com/arun11299/cpp-jwt
Python
3
star
12

conan-inja

A Conan wrapper for https://github.com/pantor/inja
Python
3
star
13

conan-cpr

Python
2
star
14

excellent-ci

A demonstration of the GitHub Checks API that uses the Excellent Ruby linter.
Ruby
2
star
15

getting-started-github-apps

2
star
16

base64

C++
2
star
17

slax

Slack Events API Explorer: A command line tool for inspecting the events Slack sends to your app
C++
2
star
18

conan-gnutls

Python
2
star
19

facetor

Excelsior! Let's use GitHub Actions make a self-building gem
Ruby
2
star
20

luna-example

Example code to build a Luna webapp
C++
2
star
21

pandia

Just serves static files quickly, making front-end development easier.
C++
1
star
22

Galileo

Galileo: a Distributed Genetic Algorithm
Python
1
star
23

proxy

A CLI tool for printing proxy MtG cards
Ruby
1
star
24

checks-api-ruby-demo

Ruby
1
star
25

conan-mongo-cxx-driver

A conan wrapper for mongocxx
Python
1
star
26

bicicletta

Hardware and software for transforming Chinese e-bike motor controllers into Bluetooth Low Energy powerhouses.
Eagle
1
star
27

ruby-devmate

Ruby bindings for the DevMate API
Ruby
1
star
28

homebrew-tools

Ruby
1
star
29

cardtagger-be

Backend for the cardtagger web application
C++
1
star
30

luna-templates

Python
1
star
31

conan-lua

A Conan wrapper for the lua scripting language
Python
1
star
32

statlerbot

A Slack bot written in pure, modern C++
C++
1
star
33

FlashFIFO

A sample implementation of a FIFO queue in NOR flash.
C
1
star