chitey-codegen

Crates.iochitey-codegen
lib.rschitey-codegen
version0.4.0
sourcesrc
created_at2023-09-26 10:26:12.624201
updated_at2023-10-08 05:34:44.084333
descriptionRouting macros for Chitey
homepage
repositoryhttps://github.com/oligami-0424/chitey.git
max_upload_size
id983485
size27,167
oligami (oligamiq)

documentation

README

メモ

マクロ適用後

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
            }
        })
}
Commit count: 90

cargo fmt