Noelle 5 лет назад
Родитель
Сommit
f7ba5adc88
1 измененных файлов: 4 добавлений и 4 удалений
  1. 4
    4
      src/main.rs

+ 4
- 4
src/main.rs Просмотреть файл

fn route(c: &str, mut r: &mut Response) { fn route(c: &str, mut r: &mut Response) {


let mut routes = vec![]; let mut routes = vec![];
routes.push(Route::new("api/hi", hi));
routes.push(Route::new("api/bye", bye));
routes.push(Route::new("api/hi", api_hi));
routes.push(Route::new("api/bye", api_bye));


// println!("Asked to fetch {}", c); // println!("Asked to fetch {}", c);
//assert!(Path::new(c).exists()); //assert!(Path::new(c).exists());
r.set_content("There is currently no API endpoint at that address."); r.set_content("There is currently no API endpoint at that address.");
} }


fn hi(_c: &&str, r: &mut Response) {
fn api_hi(_c: &&str, r: &mut Response) {
r.set_header("HTTP/1.1 200 OK\r\n\r\n"); r.set_header("HTTP/1.1 200 OK\r\n\r\n");
r.set_content("Hello there!"); r.set_content("Hello there!");
} }


fn bye(_c: &&str, r: &mut Response) {
fn api_bye(_c: &&str, r: &mut Response) {
r.set_header("HTTP/1.1 200 OK\r\n\r\n"); r.set_header("HTTP/1.1 200 OK\r\n\r\n");
r.set_content("Leaving so soon?"); r.set_content("Leaving so soon?");
} }

Загрузка…
Отмена
Сохранить