use actix_web::{get, web, App, HttpServer, HttpRequest, HttpResponse, Responder, ResponseError, Result};
use actix_web::body::BoxBody;
use actix_web::http::StatusCode;
-use image::{ImageBuffer, ColorType, Pixel, Rgb, RgbImage, write_buffer_with_format};
+use image::{ImageBuffer, ColorType, Rgb, RgbImage, write_buffer_with_format};
use image::ImageOutputFormat::Png;
use image::imageops::{FilterType, resize};
}
#[get("/gen/1/{dim_x}/{dim_y}/{scale}/{data}")]
-async fn img_gen1(req: HttpRequest, dim_x: web::Path<u16>, dim_y: web::Path<u16>, scale: web::Path<u8>) -> Result<impl Responder> {
- Ok(HttpResponse::build(StatusCode::OK))
+async fn img_gen1(req: HttpRequest, path: web::Path<(u32, u32, u32)>) -> Result<impl Responder> {
+ let (dim_x, dim_y, scale) = path.into_inner();
+ let data = req.uri().path().split("/").skip(6).next().unwrap();
+ let cursor = make_png(dim_x, dim_y, scale, percent_decode_str(&data).into_iter().borrow_mut())?;
+ Ok(HttpResponse::build(StatusCode::OK)
+ .content_type("image/png")
+ .body(cursor.into_inner()))
}
#[actix_web::main] // or #[tokio::main]