dream_http_client/recording
Recording format types and JSON codecs
Defines the structure for storing HTTP request/response recordings in a custom JSON format that supports both blocking and streaming responses.
Types
Streaming chunk with timing information
pub type Chunk {
Chunk(data: BitArray, delay_ms: Int)
}
Constructors
-
Chunk(data: BitArray, delay_ms: Int)
Recorded HTTP request
pub type RecordedRequest {
RecordedRequest(
method: http.Method,
scheme: http.Scheme,
host: String,
port: option.Option(Int),
path: String,
query: option.Option(String),
headers: List(#(String, String)),
body: String,
)
}
Constructors
-
RecordedRequest( method: http.Method, scheme: http.Scheme, host: String, port: option.Option(Int), path: String, query: option.Option(String), headers: List(#(String, String)), body: String, )
Recorded HTTP response - can be blocking or streaming
pub type RecordedResponse {
BlockingResponse(
status: Int,
headers: List(#(String, String)),
body: String,
)
StreamingResponse(
status: Int,
headers: List(#(String, String)),
chunks: List(Chunk),
)
}
Constructors
-
BlockingResponse( status: Int, headers: List(#(String, String)), body: String, ) -
StreamingResponse( status: Int, headers: List(#(String, String)), chunks: List(Chunk), )
Complete recording entry (request + response pair)
pub type Recording {
Recording(request: RecordedRequest, response: RecordedResponse)
}
Constructors
-
Recording(request: RecordedRequest, response: RecordedResponse)
Values
pub fn decode_recording_file(
json_string: String,
) -> Result(RecordingFile, String)
pub fn encode_recording_file(file: RecordingFile) -> json.Json