DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
WebApplication.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"
10#include "System/Action.h"
11#include "System/Func.h"
18
19namespace DotNetDupe {
20 namespace WebAppCore {
21 namespace Builder {
22
24
34 public:
36
39
43 DOTNETDUPE_API WebApplication& operator=(WebApplication&&) noexcept;
44
48
51 DOTNETDUPE_API DotNetDupe::System::SmartPointer<DotNetDupe::System::IServiceProvider> GetServices() const { return m_spServices; }
52
57
62
67
72
77
81
86
89
93 DOTNETDUPE_API void Run(const DotNetDupe::System::String& url = "http://127.0.0.1:5000", int threadCount = 10);
94
96 DOTNETDUPE_API void Stop();
97
98 private:
100
101 void SetControllerRegistrars(DotNetDupe::System::Collections::Generic::List<ControllerRegistrar> registrars) {
102 m_controllerRegistrars = std::move(registrars);
103 }
104
105 void SetSelfPointer(const DotNetDupe::System::SmartPointer<WebApplication>& spSelf) {
106 m_spSelf = spSelf;
107 }
108
111 void StartServerLoop(const DotNetDupe::System::String& host, int port);
112
119
121 bool m_bRunning;
123 int m_nPort;
126 };
127
128 }
129 }
130}
Encapsulates a delegate method that has parameters and returns void.
Defines common cross-platform macros, export decorators, and fundamental types.
#define DOTNETDUPE_API
Platform-specific linkage decoration for exporting or importing library symbols.
Definition Common.h:20
Encapsulates a method that has parameters and returns a value of the type specified by the TResult pa...
HTTP request, response, and context abstractions for WebAppCore processing pipelines.
Defines a mechanism for retrieving a service object; that is, an object that provides custom support ...
Represents a strongly typed list of objects that can be accessed by index mirroring ....
Base object class for DotNetDupe mirroring .NET System.Object.
Provides reference-counted and weak pointer memory management primitives ensuring zero raw ownership.
High-performance UTF-8 / UTF-16 string manipulation class mirroring .NET System.String.
Listens for connections from TCP network clients.
Context and handler abstractions for WebSockets integrated into the WebAppCore HTTP server pipeline.
Encapsulates a method that has parameters and does not return a value.
Definition Action.h:46
Represents a collection of keys and values.
Definition Dictionary.h:66
Represents a strongly typed list of objects accessible by index.
Definition List.h:29
Primary template declaration for the Func delegate family.
Definition Func.h:42
Supports all classes in the DotNetDupe class hierarchy.
Definition Object.h:18
A unified smart pointer that supports both unique and shared ownership semantics.
Represents text as a sequence of UTF-8 code units with culture-invariant operations.
Definition String.h:74
Facilitates initialization and configuration of dependency injection services, controllers,...
void MapDelete(const DotNetDupe::System::String &pattern, DotNetDupe::System::Func< DotNetDupe::System::String, DotNetDupe::System::SmartPointer< Http::HttpContext > > handler)
Registers an HTTP DELETE route endpoint with a synchronous lambda or delegate handler.
void MapPost(const DotNetDupe::System::String &pattern, DotNetDupe::System::Func< DotNetDupe::System::String, DotNetDupe::System::SmartPointer< Http::HttpContext > > handler)
Registers an HTTP POST route endpoint with a synchronous lambda or delegate handler.
DotNetDupe::System::Action< const DotNetDupe::System::SmartPointer< WebApplication > & > ControllerRegistrar
DotNetDupe::System::Collections::Generic::List< DotNetDupe::System::String > GetWebSocketRoutes() const
Retrieves the list of all currently mapped WebSocket route patterns.
void Stop()
Stops the active TCP listener and releases connection worker threads.
bool HasWebSocketRoute(const DotNetDupe::System::String &path) const
Determines whether a registered WebSocket route matches the specified path.
void MapWebSocket(const DotNetDupe::System::String &pattern, DotNetDupe::System::SmartPointer< WebSockets::IWebSocketHandler > handler)
Maps an RFC 6455 WebSocket endpoint to an asynchronous lifecycle handler.
WebApplication(const WebApplication &)=delete
void MapControllers()
Dispatches and binds all registered controller routes to this application pipeline.
WebApplication(const DotNetDupe::System::SmartPointer< DotNetDupe::System::IServiceProvider > &spServices)
void MapPut(const DotNetDupe::System::String &pattern, DotNetDupe::System::Func< DotNetDupe::System::String, DotNetDupe::System::SmartPointer< Http::HttpContext > > handler)
Registers an HTTP PUT route endpoint with a synchronous lambda or delegate handler.
static DotNetDupe::System::SmartPointer< WebApplicationBuilder > CreateBuilder()
Initializes a new instance of the WebApplicationBuilder class with pre-configured defaults.
DotNetDupe::System::SmartPointer< DotNetDupe::System::IServiceProvider > GetServices() const
Gets the service provider holding the configured application dependencies.
WebApplication & operator=(const WebApplication &)=delete
void Run(const DotNetDupe::System::String &url="http://127.0.0.1:5000", int threadCount=10)
Starts the embedded HTTP/WebSocket server listener on the specified URL and worker thread pool.
void MapGet(const DotNetDupe::System::String &pattern, DotNetDupe::System::Func< DotNetDupe::System::String, DotNetDupe::System::SmartPointer< Http::HttpContext > > handler)
Registers an HTTP GET route endpoint with a synchronous lambda or delegate handler.