NAWA 0.9
Web Application Framework for C++
nawarun.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019-2022 Tobias Flaig.
3 *
4 * This file is part of nawa.
5 *
6 * nawa is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License,
8 * version 3, as published by the Free Software Foundation.
9 *
10 * nawa is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with nawa. If not, see <https://www.gnu.org/licenses/>.
17 */
18
24#ifndef NAWA_NAWARUN_H
25#define NAWA_NAWARUN_H
26
27#include <memory>
29#include <optional>
30#include <string>
31#include <tuple>
32#include <unistd.h>
33#include <vector>
34
35namespace nawarun {
36 using PrivilegeDowngradeData = std::tuple<uid_t, gid_t, std::vector<gid_t>>;
37
38 struct Parameters {
39 using ConfigOptionId = std::pair<std::string, std::string>;
40 using ConfigOverride = std::pair<ConfigOptionId, std::string>;
41 std::optional<std::string> configFile;
42 std::vector<ConfigOverride> configOverrides;
43 };
44
45 // Types of functions that need to be accessed from NAWA applications
46 using init_t = int(nawa::AppInit&);
54 unsigned int getConcurrency(nawa::Config const& config);
55
62 std::pair<init_t*, std::shared_ptr<nawa::HandleRequestFunctionWrapper>> loadAppFunctions(nawa::Config const& config);
63
68 void reload(int signum);
69
77 std::optional<PrivilegeDowngradeData> preparePrivilegeDowngrade(nawa::Config const& config);
78
83 void replaceLogger(nawa::Log const& log);
84
92 Parameters parseCommandLine(int argc, char** argv);
93
99 int run(Parameters const& parameters);
100}// namespace nawarun
101
102#endif//NAWA_NAWARUN_H
Definition: Log.h:38
Forward declarations.
std::vector< ConfigOverride > configOverrides
Definition: nawarun.h:42
Parameters parseCommandLine(int argc, char **argv)
Definition: nawarun.cpp:340
std::optional< std::string > configFile
Definition: nawarun.h:41
std::pair< ConfigOptionId, std::string > ConfigOverride
Definition: nawarun.h:40
int(nawa::Connection &) handleRequest_t
Definition: nawarun.h:47
void reload(int signum)
Definition: nawarun.cpp:229
int(nawa::AppInit &) init_t
Definition: nawarun.h:46
unsigned int getConcurrency(nawa::Config const &config)
Definition: nawarun.cpp:184
int run(Parameters const &parameters)
Definition: nawarun.cpp:392
std::optional< PrivilegeDowngradeData > preparePrivilegeDowngrade(nawa::Config const &config)
Definition: nawarun.cpp:287
std::pair< init_t *, std::shared_ptr< nawa::HandleRequestFunctionWrapper > > loadAppFunctions(nawa::Config const &config)
Definition: nawarun.cpp:200
void replaceLogger(nawa::Log const &log)
Definition: nawarun.cpp:329
std::pair< std::string, std::string > ConfigOptionId
Definition: nawarun.h:39
std::tuple< uid_t, gid_t, std::vector< gid_t > > PrivilegeDowngradeData
Definition: nawarun.h:36