API
Mongoose.route! — Methodroute!(server::Server, method::Symbol, path::String, handler::Function)
Registers an HTTP request handler for a specific method and URI.
# Arguments
- `server::Server`: The server to register the handler with.
- `method::Symbol`: The HTTP method (e.g., :get, :post, :put, :patch, :delete).
- `path::AbstractString`: The URI path to register the handler for (e.g., "/api/users").
- `handler::Function`: The Julia function to be called when a matching request arrives.
This function should accept a `Request` object as its first argument, followed by any additional keyword arguments.Mongoose.serialize — MethodSerializes a dictionary of strings to a string of headers.
Arguments
headers::Dict{String,String}: The dictionary of strings to serialize.
Returns
String: The string of headers.
Mongoose.shutdown! — Methodshutdown!(server::Server)
Stops the running Mongoose HTTP server. Sets a flag to stop the background event loop task, and then frees the Mongoose associated resources.
Arguments
- `server::Server`: The server object to shutdown.Mongoose.shutdown! — Methodshutdown!() Stops all running servers.
Mongoose.start! — Methodstart!(server::Server; host::AbstractString="127.0.0.1", port::Integer=8080, blocking::Bool=false)
Starts the Mongoose HTTP server. Initialize the Mongoose manager, binds an HTTP listener, and starts a background Task to poll the Mongoose event loop.
Arguments
- `server::Server`: The server object to start.
- `host::AbstractString="127.0.0.1"`: The IP address or hostname to listen on. Defaults to "127.0.0.1" (localhost).
- `port::Integer=8080`: The port number to listen on. Defaults to 8080.
- `blocking::Bool=true`: If true, blocks until the server is stopped. If false, runs the server in a non-blocking mode.Mongoose.to_string — MethodConverts a dictionary of strings to a string of headers.
Arguments
headers::Dict{String,String}: The dictionary of strings to convert.
Returns
String: The string of headers.