Skip to content
Discussion options

You must be logged in to vote

This is an example of a custom webserver that you can have start on each test. It is meant as a simple starting point for someone who might want something more custom. This code has no external dependencies outside of serde/serde_json/ureq. It follows the patterns as given in the official rust book as seen here.

Given this basic server:

use serde_json::json;
use std::thread::spawn;
use std::{
    io::{BufReader, prelude::*},
    net::TcpListener,
    sync::Arc,
    sync::RwLock,
};

#[derive(Debug)]
pub struct TestServerRequest {
    pub route: String,
    #[allow(dead_code)]
    pub pathname: String,
    #[allow(dead_code)]
    pub method: String,
}

fn create_body<S: AsRef<str>, T: AsRef<…

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@bitterepic
Comment options

Comment options

You must be logged in to vote
2 replies
@algesten
Comment options

@bitterepic
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by bitterepic
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants