extern crate proc_macro;
mod common;
mod core;
mod utils;
use crate::common::{controller_macro::*, injectable_macro::*, route_macro::*};
use crate::core::module_macro::*;
use common::check_macro::check_macro;
use proc_macro::TokenStream;
#[proc_macro_attribute]
pub fn module(args: TokenStream, input: TokenStream) -> TokenStream {
module_macro(args, input)
}
#[proc_macro_attribute]
pub fn injectable(args: TokenStream, input: TokenStream) -> TokenStream {
injectable_macro(args, input)
}
#[proc_macro_attribute]
pub fn controller(args: TokenStream, input: TokenStream) -> TokenStream {
controller_macro(args, input)
}
#[proc_macro_attribute]
pub fn route(args: TokenStream, input: TokenStream) -> TokenStream {
route_macro(args, input)
}
#[proc_macro_attribute]
pub fn get(args: TokenStream, input: TokenStream) -> TokenStream {
let args = syn::parse_str::<syn::Expr>(args.to_string().as_str()).unwrap();
let args_with_method = quote::quote! { "GET", #args };
route_macro(args_with_method.into(), input)
}
#[proc_macro_attribute]
pub fn post(args: TokenStream, input: TokenStream) -> TokenStream {
let args = syn::parse_str::<syn::Expr>(args.to_string().as_str()).unwrap();
let args_with_method = quote::quote! { "POST", #args };
route_macro(args_with_method.into(), input)
}
#[proc_macro_attribute]
pub fn put(args: TokenStream, input: TokenStream) -> TokenStream {
let args = syn::parse_str::<syn::Expr>(args.to_string().as_str()).unwrap();
let args_with_method = quote::quote! { "PUT", #args };
route_macro(args_with_method.into(), input)
}
#[proc_macro_attribute]
pub fn delete(args: TokenStream, input: TokenStream) -> TokenStream {
let args = syn::parse_str::<syn::Expr>(args.to_string().as_str()).unwrap();
let args_with_method = quote::quote! { "DELETE", #args };
route_macro(args_with_method.into(), input)
}
#[proc_macro_attribute]
pub fn patch(args: TokenStream, input: TokenStream) -> TokenStream {
let args = syn::parse_str::<syn::Expr>(args.to_string().as_str()).unwrap();
let args_with_method = quote::quote! { "PATCH", #args };
route_macro(args_with_method.into(), input)
}
#[proc_macro_attribute]
pub fn head(args: TokenStream, input: TokenStream) -> TokenStream {
let args = syn::parse_str::<syn::Expr>(args.to_string().as_str()).unwrap();
let args_with_method = quote::quote! { "HEAD", #args };
route_macro(args_with_method.into(), input)
}
#[proc_macro_attribute]
pub fn check(args: TokenStream, input: TokenStream) -> TokenStream {
check_macro(args, input)
}