use crate::*; use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; use near_sdk::near_bindgen; use near_sdk::serde::{Deserialize, Serialize}; use std::str; #[allow(non_snake_case)] #[derive(BorshDeserialize, BorshSerialize, Serialize, Deserialize)] #[serde(crate = "near_sdk::serde")] pub struct Web4Request { accountId: Option, path: String, } #[allow(non_snake_case)] #[derive(BorshDeserialize, BorshSerialize, Serialize, Deserialize)] #[serde(crate = "near_sdk::serde")] pub struct Web4Response { contentType: String, body: Vec, preloadUrls: Vec, } #[near_bindgen] impl Exchange { pub fn web4_get(&self, request: Web4Request) -> Web4Response { let (content_type, body) = if request.path == "/".to_string() { ("text/html", include_bytes!("../simple_ui.html").to_vec()) } else if request.path == "/src".to_string() { ("text/html", include_bytes!("../src_list.html").to_vec()) } else if request.path == "/simple_ui.html".to_string() { ("text/plain", include_bytes!("../simple_ui.html").to_vec()) } else if request.path == "/src_list.html".to_string() { ("text/plain", include_bytes!("../src_list.html").to_vec()) } else if request.path == "/README.md".to_string() { ("text/plain", include_bytes!("../README.md").to_vec()) } else if request.path == "/Cargo.toml".to_string() { ("text/plain", include_bytes!("../Cargo.toml").to_vec()) } else if request.path == "/src/heap.rs".to_string() { ("text/plain", include_bytes!("heap.rs").to_vec()) } else if request.path == "/src/lib.rs".to_string() { ("text/plain", include_bytes!("lib.rs").to_vec()) } else if request.path == "/src/pair.rs".to_string() { ("text/plain", include_bytes!("pair.rs").to_vec()) } else if request.path == "/src/price_point.rs".to_string() { ("text/plain", include_bytes!("price_point.rs").to_vec()) } else if request.path == "/src/rate.rs".to_string() { ("text/plain", include_bytes!("rate.rs").to_vec()) } else if request.path == "/src/web4.rs".to_string() { ("text/plain", include_bytes!("web4.rs").to_vec()) } else { ("text/plain", "Not found".as_bytes().to_vec()) }; Web4Response { contentType: content_type.to_string(), body, preloadUrls: vec![], } } }