Crates.io | chitey-codegen |
lib.rs | chitey-codegen |
version | 0.4.0 |
source | src |
created_at | 2023-09-26 10:26:12.624201 |
updated_at | 2023-10-08 05:34:44.084333 |
description | Routing macros for Chitey |
homepage | |
repository | https://github.com/oligami-0424/chitey.git |
max_upload_size | |
id | 983485 |
size | 27,167 |
cargo install cargo-expand cargo expand
fn main() {
let body = async {
{
::std::io::_print(format_args!("Hello, world!\n"));
};
};
#[allow(clippy::expect_used, clippy::diverging_sub_expression)]
{
return tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.expect("Failed building the Runtime")
.block_on(body);
}
}
#[allow(non_camel_case_types, missing_docs)]
pub struct greet;
impl ::chitey::HttpServiceFactory for greet {
fn register(&self) -> ::chitey::Resource {
async fn greet(name: String) -> Responder {
{
::std::io::_print(format_args!("Hello {0}!\n", name));
};
let builder = Response::builder();
let ret = Bytes::copy_from_slice(b"source");
Ok((builder, ret))
}
let __resource = ::chitey::Resource::new("/hello/{name}").regist(greet);
return __resource;
}
}
#[allow(non_camel_case_types, missing_docs)]
pub struct doubb;
impl ::chitey::HttpServiceFactory for doubb {
fn register(&self) -> ::chitey::Resource {
async fn doubb((name, id): (u32, String)) -> Responder {
{
let res = ::alloc::fmt::format(
format_args!("Hello {0}! id:{1}", name, id),
);
res
};
let builder = Response::builder();
let ret = Bytes::copy_from_slice(b"source");
Ok((builder, ret))
}
let __resource = ::chitey::Resource::new("/{id}/{name}").regist(doubb);
return __resource;
}
}
#![feature(prelude_import)]
#[prelude_import]
use std::prelude::rust_2021::*;
#[macro_use]
extern crate std;
use actix_web::{get, web, App, HttpServer, Responder};
#[allow(non_camel_case_types, missing_docs)]
pub struct greet;
impl ::actix_web::dev::HttpServiceFactory for greet {
fn register(self, __config: &mut actix_web::dev::AppService) {
async fn greet(req: web::Path<(u32, String)>) -> impl Responder {
let (name, id) = req.to_owned();
{
let res = ::alloc::fmt::format(
format_args!("Hello {0}! id:{1}", name, id),
);
res
}
}
let __resource = ::actix_web::Resource::new("/{id}/{name}")
.name("greet")
.guard(::actix_web::guard::Get())
.to(greet);
::actix_web::dev::HttpServiceFactory::register(__resource, __config);
}
}
fn main() -> std::io::Result<()> {
<::actix_web::rt::System>::new()
.block_on(async move {
{
HttpServer::new(|| { App::new().service(greet) })
.bind("127.0.0.1:8080")?
.run()
.await
}
})
}