FakeHTTP v0.1.0 FakeHTTP.Server View Source
The main interface of a scriptable HTTP server
Link to this section Summary
Functions
Returns a corresponding agent name or raises error
Returns a specification to start this module under a supervisor
Enqueue a new response which will return from the HTTP server
Resets the internal states in the server
Shutdown the server
Link to this section Types
Link to this type
body() View Source
Link to this type
headers() View Source
Link to this type
on_start() View Source
Link to this type
options()
View Source
options()
View Source
options() :: [GenServer.option()]
options() :: [GenServer.option()]
Link to this type
server()
View Source
server()
View Source
server() :: GenServer.server()
server() :: GenServer.server()
Link to this type
status_code() View Source
Link to this section Functions
Link to this function
agent!(server)
View Source
agent!(server)
View Source
agent!(server()) :: GenServer.server() | no_return()
agent!(server()) :: GenServer.server() | no_return()
Returns a corresponding agent name or raises error.
Link to this function
base_url(server) View Source
Link to this function
child_spec(arg) View Source
Returns a specification to start this module under a supervisor.
See Supervisor
.
Link to this function
enqueue(server, raw_response) View Source
Enqueue a new response which will return from the HTTP server.
Examples
Server.enqueue(server, 200) # 200 OK
Server.enqueue(server, :forbidden) # 403 Forbidden
Server.enqueue(server, %{"x" => 12345}) # application/json
Server.enqueue(server, "hello, world!") # text/plain
Server.enqueue(server, 400, %{error: "bad_request"}) # 403 Forbidden + application/json
Link to this function
enqueue(server, status_code, body)
View Source
enqueue(server, status_code, body)
View Source
enqueue(server(), status_code(), body()) :: :ok | no_return()
enqueue(server(), status_code(), body()) :: :ok | no_return()
Link to this function
enqueue(server, status_code, body, headers)
View Source
enqueue(server, status_code, body, headers)
View Source
enqueue(server(), status_code(), body(), headers()) :: :ok | no_return()
enqueue(server(), status_code(), body(), headers()) :: :ok | no_return()
Link to this function
reset(server)
View Source
reset(server)
View Source
reset(server()) :: :ok
reset(server()) :: :ok
Resets the internal states in the server
.
Link to this function
start_link(opts \\ []) View Source
Link to this function
stop(server)
View Source
stop(server)
View Source
stop(server()) :: :ok
stop(server()) :: :ok
Shutdown the server
.
Link to this function
take(server)
View Source
take(server)
View Source
take(server()) :: {:ok, FakeHTTP.Request.t()} | :error
take(server()) :: {:ok, FakeHTTP.Request.t()} | :error