melvin_ob/http_handler/http_request/
objective_image_post.rs1use super::objective_image::ObjectiveImageResponse;
2use super::request_common::{
3 HTTPRequestMethod, HTTPRequestType, MultipartBodyHTTPRequestType,
4};
5use std::{collections::HashMap, path::PathBuf};
6
7#[derive(Debug)]
9pub(crate) struct ObjectiveImageRequest {
10 image_path: PathBuf,
12 objective_id: usize,
14}
15
16impl MultipartBodyHTTPRequestType for ObjectiveImageRequest {
17 fn image_path(&self) -> &PathBuf { &self.image_path }
19}
20
21impl HTTPRequestType for ObjectiveImageRequest {
22 type Response = ObjectiveImageResponse;
24 fn endpoint(&self) -> &'static str { "/image" }
26 fn request_method(&self) -> HTTPRequestMethod { HTTPRequestMethod::Post }
28 fn query_params(&self) -> HashMap<&str, String> {
30 let mut query = HashMap::new();
31 query.insert("objective_id", self.objective_id.to_string());
32 query
33 }
34}
35
36impl ObjectiveImageRequest {
37 pub fn new(objective_id: usize, image_path: PathBuf) -> Self {
39 Self { image_path, objective_id }
40 }
41}