Skip to content

Commit

Permalink
Remove more dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
drakeerv committed Dec 2, 2024
1 parent 284e7fb commit 8989155
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pasted"
version = "1.2.29"
version = "1.2.30"
edition = "2021"
authors = ["drakeerv <drakeerv@outlook.com>"]
description = "A pastebin frontend written in Rust"
Expand Down
18 changes: 10 additions & 8 deletions src/client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use scraper::Html;
use ureq::{Agent, AgentBuilder};
use std::fmt;
use std::io::Read;

#[derive(Clone)]
pub struct Client {
Expand Down Expand Up @@ -62,22 +63,23 @@ impl Client {

pub fn get_bytes(&self, url: &str) -> Result<Vec<u8>, ClientError> {
let mut data = Vec::new();
self.agent
let mut reader = self.agent
.get(url)
.call()
.unwrap()
.into_reader()
.read_to_end(&mut data)
.unwrap();
.call()?
.into_reader();

reader.read_to_end(&mut data)?;
Ok(data)
}

pub fn get_html(&self, url: &str) -> Result<Html, ClientError> {
Ok(Html::parse_document(&&self.get_string(url)?))
self.get_string(url)
.map(|s| Html::parse_document(&s))
}

pub fn post_html(&self, url: &str, form: (String, Vec<u8>)) -> Result<Html, ClientError> {
Ok(Html::parse_document(&self.post_string(url, form)?))
self.post_string(url, form)
.map(|s| Html::parse_document(&s))
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/routes/imgs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use axum::{
body::Body, extract::{Path, State}, http::StatusCode, response::{IntoResponse, Response}, routing, Router
body::Body, extract::{Path, State}, http::StatusCode, response::Response, routing, Router
};

use crate::{state::AppState, constants::URL};
Expand Down Expand Up @@ -66,6 +66,8 @@ async fn icon(

#[cfg(test)]
mod tests {
use axum::response::IntoResponse as _;

use super::*;

#[tokio::test]
Expand Down

0 comments on commit 8989155

Please sign in to comment.