DotNetDupe
4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Toggle main menu visibility
Loading...
Searching...
No Matches
WebAppServer.h
Go to the documentation of this file.
1
3
4
#pragma once
5
6
#include "
Common.h
"
7
#include "
System/Object.h
"
8
#include "
System/String.h
"
9
#include "
System/SmartPointer.h
"
10
#include "
WebAppCore/Builder/WebApplication.h
"
11
12
namespace
DotNetDupe
{
13
namespace
WebAppCore
{
14
namespace
Server
{
15
24
class
WebAppServer
:
public
virtual
DotNetDupe::System::Object
{
25
public
:
30
DOTNETDUPE_API
explicit
WebAppServer
(
const
DotNetDupe::System::SmartPointer<Builder::WebApplication>
& app,
const
DotNetDupe::System::String
& webRoot =
"wwwroot"
);
31
33
DOTNETDUPE_API
~WebAppServer
()
override
=
default
;
34
35
WebAppServer
(
const
WebAppServer
&) =
delete
;
36
WebAppServer
&
operator=
(
const
WebAppServer
&) =
delete
;
37
40
DOTNETDUPE_API
WebAppServer
(
WebAppServer
&& other)
noexcept
;
41
45
DOTNETDUPE_API
WebAppServer
&
operator=
(
WebAppServer
&& other)
noexcept
;
46
49
DOTNETDUPE_API
void
SetWebRoot
(
const
DotNetDupe::System::String
& webRoot) { m_sWebRoot = webRoot; }
50
53
DOTNETDUPE_API
DotNetDupe::System::String
GetWebRoot
()
const
{
return
m_sWebRoot; }
54
57
DOTNETDUPE_API
void
EnableStaticFiles
(
const
DotNetDupe::System::String
& defaultDocument =
"index.html"
);
58
62
DOTNETDUPE_API
void
Run
(
const
DotNetDupe::System::String
& url =
"http://localhost:8080/index.html"
,
int
threadCount = 10);
63
65
DOTNETDUPE_API
void
Stop
();
66
70
DOTNETDUPE_API
static
DotNetDupe::System::String
GetMimeType
(
const
DotNetDupe::System::String
& filePath);
71
72
private
:
73
DotNetDupe::System::SmartPointer<Builder::WebApplication>
m_spApp;
74
DotNetDupe::System::String
m_sWebRoot;
75
DotNetDupe::System::String
m_sDefaultDocument;
76
bool
m_bStaticFilesEnabled;
77
};
78
79
}
80
}
81
}
Common.h
Defines common cross-platform macros, export decorators, and fundamental types.
DOTNETDUPE_API
#define DOTNETDUPE_API
Platform-specific linkage decoration for exporting or importing library symbols.
Definition
Common.h:20
Object.h
Base object class for DotNetDupe mirroring .NET System.Object.
SmartPointer.h
Provides reference-counted and weak pointer memory management primitives ensuring zero raw ownership.
String.h
High-performance UTF-8 / UTF-16 string manipulation class mirroring .NET System.String.
WebApplication.h
Represents the web application used to configure the HTTP pipeline and routes mirroring ASP....
DotNetDupe::System::Object
Supports all classes in the DotNetDupe class hierarchy.
Definition
Object.h:18
DotNetDupe::System::SmartPointer
A unified smart pointer that supports both unique and shared ownership semantics.
Definition
SmartPointer.h:72
DotNetDupe::System::String
Represents text as a sequence of UTF-8 code units with culture-invariant operations.
Definition
String.h:74
DotNetDupe::WebAppCore::Server::WebAppServer::~WebAppServer
~WebAppServer() override=default
Virtual destructor.
DotNetDupe::WebAppCore::Server::WebAppServer::SetWebRoot
void SetWebRoot(const DotNetDupe::System::String &webRoot)
Sets the local filesystem directory path from which static files are served.
Definition
WebAppServer.h:49
DotNetDupe::WebAppCore::Server::WebAppServer::WebAppServer
WebAppServer(const DotNetDupe::System::SmartPointer< Builder::WebApplication > &app, const DotNetDupe::System::String &webRoot="wwwroot")
Constructs a WebAppServer wrapping the specified WebApplication host and web root path.
Definition
WebAppServer.cpp:18
DotNetDupe::WebAppCore::Server::WebAppServer::GetMimeType
static DotNetDupe::System::String GetMimeType(const DotNetDupe::System::String &filePath)
Resolves the standard MIME content type string based on a file path extension.
Definition
WebAppServer.cpp:52
DotNetDupe::WebAppCore::Server::WebAppServer::operator=
WebAppServer & operator=(const WebAppServer &)=delete
DotNetDupe::WebAppCore::Server::WebAppServer::EnableStaticFiles
void EnableStaticFiles(const DotNetDupe::System::String &defaultDocument="index.html")
Enables static file serving with the specified default document fallback.
Definition
WebAppServer.cpp:46
DotNetDupe::WebAppCore::Server::WebAppServer::Stop
void Stop()
Stops the running web server and active TCP listener.
Definition
WebAppServer.cpp:139
DotNetDupe::WebAppCore::Server::WebAppServer::WebAppServer
WebAppServer(const WebAppServer &)=delete
DotNetDupe::WebAppCore::Server::WebAppServer::GetWebRoot
DotNetDupe::System::String GetWebRoot() const
Gets the configured web root directory path.
Definition
WebAppServer.h:53
DotNetDupe::WebAppCore::Server::WebAppServer::Run
void Run(const DotNetDupe::System::String &url="http://localhost:8080/index.html", int threadCount=10)
Starts the underlying WebApplication server listener on the specified URL and thread pool size.
Definition
WebAppServer.cpp:128
DotNetDupe::WebAppCore::Server
Definition
WebAppServer.h:14
DotNetDupe::WebAppCore
Definition
WebApplication.h:20
DotNetDupe
Definition
IServiceCollection.h:7
Include
WebAppCore
Server
WebAppServer.h
Generated by
1.18.0