Compare commits
2 commits
master
...
feature/ht
Author | SHA1 | Date | |
---|---|---|---|
11db47b005 | |||
f4b4d6a02d |
6 changed files with 16 additions and 12 deletions
|
@ -1,7 +1,3 @@
|
||||||
# 1.1.2 / 2025-03-04
|
|
||||||
- Remove unused enum member
|
|
||||||
- Bump lucide vendored dependency to `16a18f79`
|
|
||||||
|
|
||||||
# 1.1.1
|
# 1.1.1
|
||||||
- Remove caching for `/info` (and all non-Bytes responses)
|
- Remove caching for `/info` (and all non-Bytes responses)
|
||||||
- Extract error function to a macro
|
- Extract error function to a macro
|
||||||
|
|
|
@ -20,6 +20,8 @@ If you are deploying to production, you can provide a directory path in the firs
|
||||||
|
|
||||||
Only `.svg` files will be read from that directory. The server's default port is `7878`, although this can be configured with the `PORT` environment variable.
|
Only `.svg` files will be read from that directory. The server's default port is `7878`, although this can be configured with the `PORT` environment variable.
|
||||||
|
|
||||||
|
It is recommended to place a reverse proxy in front of luciders to provide caching support, response compression and other optimisations that are out of scope for this project.
|
||||||
|
|
||||||
# Docker
|
# Docker
|
||||||
You can build and run this project with Docker. The Dockerfile is configured to use the submodule for the icons. To build the image:
|
You can build and run this project with Docker. The Dockerfile is configured to use the submodule for the icons. To build the image:
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
http::{
|
error, http::{
|
||||||
requests::{Request, RequestStatus, Url},
|
requests::{Request, RequestStatus, Url},
|
||||||
responses::{Body, Response, UnitOrBoxedError},
|
responses::{Body, Response, UnitOrBoxedError},
|
||||||
},
|
}, threads::ThreadPool
|
||||||
threads::ThreadPool,
|
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
|
@ -65,7 +64,7 @@ impl Handlers {
|
||||||
RequestStatus::Ok(req) => req,
|
RequestStatus::Ok(req) => req,
|
||||||
RequestStatus::MalformedHTTP(stream) => {
|
RequestStatus::MalformedHTTP(stream) => {
|
||||||
stream.shutdown(Shutdown::Both).unwrap_or_else(|_| {
|
stream.shutdown(Shutdown::Both).unwrap_or_else(|_| {
|
||||||
eprintln!("Failed to close malformed HTTP stream")
|
error!("Failed to shutdown malformed HTTP stream")
|
||||||
});
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ use std::{error::Error, io::prelude::*, net::TcpStream};
|
||||||
use super::requests::Request;
|
use super::requests::Request;
|
||||||
|
|
||||||
pub enum Body {
|
pub enum Body {
|
||||||
|
String(String),
|
||||||
Static(&'static str),
|
Static(&'static str),
|
||||||
Bytes(Vec<u8>, &'static str),
|
Bytes(Vec<u8>, &'static str),
|
||||||
}
|
}
|
||||||
|
@ -56,6 +57,7 @@ fn send_response(mut stream: TcpStream, status: u16, body: Body) -> UnitOrBoxedE
|
||||||
response.push_str(&format!(
|
response.push_str(&format!(
|
||||||
"Content-Length: {}\r\n",
|
"Content-Length: {}\r\n",
|
||||||
match &body {
|
match &body {
|
||||||
|
Body::String(s) => s.len(),
|
||||||
Body::Static(s) => s.len(),
|
Body::Static(s) => s.len(),
|
||||||
Body::Bytes(b, _) => b.len(),
|
Body::Bytes(b, _) => b.len(),
|
||||||
}
|
}
|
||||||
|
@ -66,11 +68,16 @@ fn send_response(mut stream: TcpStream, status: u16, body: Body) -> UnitOrBoxedE
|
||||||
response.push_str("Cache-Control: immutable, public, max-age=604800\r\n");
|
response.push_str("Cache-Control: immutable, public, max-age=604800\r\n");
|
||||||
}
|
}
|
||||||
Body::Static(_) => response.push_str("Content-Type: text/plain; charset=utf-8\r\n"),
|
Body::Static(_) => response.push_str("Content-Type: text/plain; charset=utf-8\r\n"),
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
response.push_str("\r\n");
|
response.push_str("\r\n");
|
||||||
|
|
||||||
// Body
|
// Body
|
||||||
if let Body::Static(s) = &body { response.push_str(s) }
|
match &body {
|
||||||
|
Body::String(s) => response.push_str(s),
|
||||||
|
Body::Static(s) => response.push_str(s),
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
match stream.write(response.as_bytes()) {
|
match stream.write(response.as_bytes()) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
|
|
|
@ -133,7 +133,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.url.query.contains_key("discord_compatibility") {
|
if let Some(_) = req.url.query.get("discord_compatibility") {
|
||||||
padding = 8;
|
padding = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ fn main() {
|
||||||
icon_string = icon_string.replace("currentColor", svg_stroke);
|
icon_string = icon_string.replace("currentColor", svg_stroke);
|
||||||
|
|
||||||
let mut backwards_compatibility = false;
|
let mut backwards_compatibility = false;
|
||||||
if req.url.query.contains_key("backwards_compatibility") {
|
if let Some(_) = req.url.query.get("backwards_compatibility") {
|
||||||
backwards_compatibility = true;
|
backwards_compatibility = true;
|
||||||
// Icons were 80x80 plus 8px of padding; Icons start at 24x24 now so: 80 - 8 = 72, 72 / 24 = 3 therefore scale is 3x.
|
// Icons were 80x80 plus 8px of padding; Icons start at 24x24 now so: 80 - 8 = 72, 72 / 24 = 3 therefore scale is 3x.
|
||||||
scale = 3;
|
scale = 3;
|
||||||
|
|
2
vendor/lucide
vendored
2
vendor/lucide
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 16a18f790881adc6f44767edac29bfc2b42b8dc5
|
Subproject commit 11b95f883a089f8596f85200298e01558b5db877
|
Loading…
Reference in a new issue