fey 0.0.2

fey is a fast and reliable username scanner
Documentation
use reqwest::Client;
use reqwest::StatusCode;
use crate::utils::error::Error;
use crate::utils::helper;

//TODO: error handling
pub async fn scanner<'a>(url: &String) -> helper::Result<StatusCode> {
    //let response =   reqwest::get(url);
    /*
    let request = Request::new(Method::HEAD, Url::parse(url).unwrap());
    let client = Client::new();
    Client::execute(&client, request);
    */

    // make a head request for speed
    let build_response = match Client::builder().build(){
        Ok(good_client) => good_client,
        Err(error) =>{
            let errormsg = format!("TLS backend cannot be initialized, or the resolver cannot load the system configuration: {}", error);
            return Err(Error::FatalError(errormsg));
        } 
    };

    let response = build_response.head(url).send();

    // TODO: sent a signal to hop to the next line urls.txt, if the current url can't be parsed
    // making it not a fatalerror but just an error
    match response.await {
        Ok(response) => Ok(response.status()),
        Err(error) =>{
            let errormsg = format!("url could not be parsed: {}", error);
            Err(Error::FatalError(errormsg))
        },
    }
}