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::document::Document;
use select::predicate::Name; use select::predicate::Name;
use serde::{Serialize, Deserialize}; use serde_derive::{Serialize, Deserialize};
use crate::request;
// config structure // config structure
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
@ -36,7 +38,7 @@ impl Configuration {
port = self.port port = self.port
); );
let response = get_request(&request); let response = request::get_request(&request);
match response { match response {
Ok(res) => { Ok(res) => {
let document = Document::from_read(res) let document = Document::from_read(res)
@ -58,7 +60,7 @@ impl Configuration {
port = self.port port = self.port
); );
let response = get_request(&request); let response = request::get_request(&request);
match response { match response {
Ok(res) => { Ok(res) => {
let document = Document::from_read(res) let document = Document::from_read(res)
@ -84,8 +86,3 @@ pub fn init_config() -> Configuration {
config 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 app;
mod config; mod config;
mod generate; mod generate;
mod request;
const NUM_LEDS: usize = 150; 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
}