Skip to content

Instantly share code, notes, and snippets.

View alexliesenfeld's full-sized avatar

Alexander Liesenfeld alexliesenfeld

View GitHub Profile
@alexliesenfeld
alexliesenfeld / Cargo.toml
Created March 27, 2024 22:31
Rustls IP Address as SNI Example Project
[package]
name = "rustls-sni"
version = "0.1.0"
edition = "2021"
[dev-dependencies]
rustls = "0.22"
tokio-rustls = "0.25"
curl = "0.4"
reqwest = "0.11"
@alexliesenfeld
alexliesenfeld / main.rs
Last active December 16, 2021 20:36
[BLOG] main.rs test | Mocking HTTP Services in Rust with httpmock
#[cfg(test)]
mod tests {
use crate::GithubClient;
use httpmock::MockServer;
use serde_json::json;
#[test]
fn create_repo_success_test() {
// Arrange
let server = MockServer::start();
@alexliesenfeld
alexliesenfeld / main.rs
Last active December 16, 2021 08:35
[BLOG] main.rs client | Mocking HTTP Services in Rust with httpmock
use isahc::{ReadResponseExt, Request, RequestExt};
use serde_json::{json, Value};
use anyhow::{Result,ensure};
pub struct GithubClient {
base_url: String,
token: String,
}
impl GithubClient {
@alexliesenfeld
alexliesenfeld / output.txt
Last active December 16, 2021 08:34
[BLOG] output.txt | Mocking HTTP Services in Rust with httpmock
At least one request has been received, but none exactly matched the mock specification.
Here is a comparison with the most similar request (request number 1):
1 : Expected header with name 'Content-Type' and value 'application/json' to be present in the request but it wasn't.
------------------------------------------------------------------------------------------
Expected: [key=equals, value=equals] Content-Type=application/json
Actual (closest match): content-type=text/plain
@alexliesenfeld
alexliesenfeld / Cargo.toml
Last active December 16, 2021 08:36
[BLOG] dev-dependencies | Mocking HTTP Services in Rust with httpmock
[dev-dependencies]
httpmock = "0.6"
@alexliesenfeld
alexliesenfeld / comparison.csv
Last active December 16, 2021 08:35
[BLOG] comparison matrix | Mocking HTTP Services in Rust with httpmock
Library Execution Pooling Custom Matchers Mockable APIs Sync Async Stand-alone Mode
mockito serial no no 1 yes no no
httpmock parallel yes yes unlimited yes yes yes
httptest parallel yes yes unlimited yes no no
wiremock parallel no yes unlimited no yes no
@alexliesenfeld
alexliesenfeld / Cargo.toml
Last active December 16, 2021 08:35
[BLOG] Cargo.toml dependencies | Mocking HTTP Services in Rust with httpmock
[dependencies]
isahc = { version = "1.6", features = ["json"]}
serde_json = "1.0"
anyhow = "1.0"
@alexliesenfeld
alexliesenfeld / logback-spring.xml
Last active September 14, 2023 04:53
Spring Boot logging configuration for JSON output
<!--
Make sure you have the logback encoder in your dependencies:
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>5.2</version>
</dependency>
-->
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
@alexliesenfeld
alexliesenfeld / Smoother.h
Last active January 27, 2019 14:58
A C++ class to smooth out DSP parameters
#ifndef SMOOTHER_H
#define SMOOTHER_H
#include <math.h>
class Smoother {
private:
double mSampleRate;
double mLastOutput{};
double mA{};