http_server_mock/internal/server_impl
Types
pub type ServerState {
ServerState(
stubs: List(http_server_mock.Stub),
recorded_requests: List(
#(
request.Request(String),
option.Option(http_server_mock.Stub),
),
),
)
}
Constructors
-
ServerState( stubs: List(http_server_mock.Stub), recorded_requests: List( #( request.Request(String), option.Option(http_server_mock.Stub), ), ), )
Values
pub fn add_stub(
state: ServerState,
stub: http_server_mock.Stub,
) -> ServerState
pub fn clear_requests(state: ServerState) -> ServerState
pub fn clear_stubs(state: ServerState) -> ServerState
pub fn get_requests(
state: ServerState,
) -> List(request.Request(String))
pub fn get_requests_by_stub(
state: ServerState,
stub_to_match: http_server_mock.Stub,
) -> List(request.Request(String))
pub fn get_unmatched_requests(
state: ServerState,
) -> List(request.Request(String))
pub fn handle_request(
state: ServerState,
method_string: String,
path: String,
query: String,
headers: List(#(String, String)),
body: String,
host: String,
port: String,
on_result: fn(
ServerState,
Bool,
Int,
List(#(String, String)),
String,
) -> Nil,
) -> Nil
Handles one incoming request: builds a Request(String) from primitive
fields (the shape the transport worker can hand over as plain data),
finds the matching stub via the same router the Erlang runtime uses,
updates recorded requests, and calls on_result with the new state plus
the outcome - kept as primitives too, so the FFI transport layer never
has to inspect a Gleam Option/Response value directly.
pub fn initial_state(
stubs: List(http_server_mock.Stub),
) -> ServerState
pub fn remove_stub(
state: ServerState,
stub_to_remove: http_server_mock.Stub,
) -> ServerState