26 lines
594 B
Rust
26 lines
594 B
Rust
use libspace::wiki::*;
|
|
|
|
use actix_web::{get, web, Responder, Result};
|
|
|
|
#[get("/wiki/{name}")]
|
|
async fn index(name: web::Path<String>) -> Result<impl Responder> {
|
|
let obj = Page {
|
|
title: name.to_string(),
|
|
content: vec![Paragraph {
|
|
heading: "Heading".to_string(),
|
|
text: "Text".to_string(),
|
|
}],
|
|
};
|
|
Ok(web::Json(obj))
|
|
}
|
|
|
|
#[actix_web::main]
|
|
async fn main() -> std::io::Result<()> {
|
|
use actix_web::{App, HttpServer};
|
|
|
|
HttpServer::new(|| App::new().service(index))
|
|
.bind(("127.0.0.1", 8080))?
|
|
.run()
|
|
.await
|
|
}
|