added request.rs

This commit is contained in:
Wyatt J. Miller 2020-05-24 18:49:31 +01:00
parent c8b3892389
commit e4473f6566
3 changed files with 10 additions and 8 deletions

View File

@ -4,7 +4,9 @@ use std::path::Path;
use select::document::Document;
use select::predicate::Name;
use serde::{Serialize, Deserialize};
use serde_derive::{Serialize, Deserialize};
use crate::request;
// config structure
#[derive(Serialize, Deserialize, Debug)]
@ -36,7 +38,7 @@ impl Configuration {
port = self.port
);
let response = get_request(&request);
let response = request::get_request(&request);
match response {
Ok(res) => {
let document = Document::from_read(res)
@ -58,7 +60,7 @@ impl Configuration {
port = self.port
);
let response = get_request(&request);
let response = request::get_request(&request);
match response {
Ok(res) => {
let document = Document::from_read(res)
@ -83,9 +85,4 @@ pub fn init_config() -> Configuration {
let config: Configuration = serde_json::from_str(&data).expect("Couldn't parse JSON!");
config
}
pub fn get_request(request: &String) -> Result<reqwest::Response, reqwest::Error> {
let response = reqwest::get(request);
response
}

View File

@ -10,6 +10,7 @@ use ws2812_spi::Ws2812;
mod app;
mod config;
mod generate;
mod request;
const NUM_LEDS: usize = 150;

4
src/request.rs Normal file
View File

@ -0,0 +1,4 @@
pub fn get_request(request: &String) -> Result<reqwest::Response, reqwest::Error> {
let response = reqwest::get(request);
response
}