WaServer class
A class that represents the web server for handling HTTP requests and database operations.
The WaServer
class is responsible for initializing and starting the web server, managing HTTP requests,
handling routes, connecting to MongoDB, and managing scheduled tasks (cron jobs). It also provides methods
for adding routing functions and stopping the server.
Constructors
-
WaServer({required WaConfigs configs, Future<
WebRequest> onRequest(WebRequest rq)?}) -
Creates an instance of WaServer with the specified WaConfigs and an optional
onRequest
function.
Properties
-
crons
→ List<
WaCron> -
A list of WaCron instances representing scheduled tasks.
final
- db → Db
-
Gets the MongoDB database instance.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasSocket → bool
-
A boolean indicating if the server has an active WebSocket manager.
no setter
-
onRequest
↔ Future<
WebRequest> Function(WebRequest rq)? -
A function that takes a WebRequest and returns a Future containing the modified WebRequest.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- server ↔ HttpServer?
-
The HTTP server instance.
getter/setter pair
- socketManager ↔ SocketManager?
-
Manages WebSocket connections.
getter/setter pair
Methods
-
addRouting(
Future< List< router(WebRequest rq)) → WaServerWebRoute> > - Adds a routing function to the server.
-
connectMongoDb(
) → Future< Db> - Connects to MongoDB using the connection string from the configuration.
-
getAllRoutes(
WebRequest rq) → Future< List< WebRoute> > - Get routing list of Server Here you can get all routing of server that added to server Returns a list of WebRoute instances.
-
handleRequests(
HttpServer server) → Future< void> - Handles incoming HTTP requests by processing them through routing functions and the onRequest function.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerCron(
WaCron cron) → void - Registers a WaCron instance to be scheduled.
-
start(
) → Future< HttpServer> - Starts the server and binds it to the specified IP and port.
-
stop(
{bool force = true}) → Future - Stops the server and closes the database connection.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
-
appLanguages
↔ Map<
String, Map< String, String> > -
A map of application languages, where the key is the language code and the value is a map of strings.
getter/setter pair
- config ↔ WaConfigs
-
The server configuration.
getter/setter pair
- info → _Info
-
Provides information about the version of the server.
final