Actually, for the url parts, what our design is use APP.url("formatted_string") to form an instance of endpoint, that endpoint instance is internally linked to the static app instance named APP, and the attributes are things registered to that url instance. That's the reason I keep that design and I don't know whether this explanation is good or not. What that field actually is, is a field which plug in an instance of URL but not simply the string since we need to know which APP you register that URL (we are planning to support multi-app)
For function/endpoint name, you may use _ at that place if you want to make it anonymous (I keep that field just to make the endpoint and middleware looks identical)
For pub, it is just a reserved field for future integration of internal calls (which is still In planning stage, and that keyword is optional)
So, actually, an minimal endpoint looks like
endpoint!{
APP.url("/simple")
_ <HTTP> {
akari_render!("index.html")
}
}
I am thinking if it is a good idea to add "flavour" to syntax and let user to choose whether to use the original, rusty custom macro or even more rusty - direct attribute macro. That will be easy to impl though (because before 0.7 version, which is the actual ancestor of our framework did in proc_macro), its syntax looks line
#[url(APP.reg_from(&[TEST_URL.clone(), LitUrl("get")]), config=[HttpSafety::new().with_allowed_method(HttpMethod::GET)])]
async fn get_only() -> HttpResponse {
text_response("Get only")
}
#[url(APP.reg_from(&[TEST_URL.clone(), LitUrl("post")]), config=[HttpSafety::new().with_allowed_methods(vec![HttpMethod::POST])])]
async fn post_only() -> HttpResponse {
text_response("Post only")
}
Maybe we can simplify the URL reg into the new way and keep that proc macro (which looks like this?) as one of the option user can choose
#[endpoint(APP.url("/test/reg"), config=[HttpSafety::new().with_allowed_method(HttpMethod::GET)])]
async fn get_only() -> HttpResponse {
text_response("Get only")
}
For middleware, we use UpperCamelCase because the struct will be generated when the macro is expanded (so fundamentally, it is not a function). Do you think it will be better if we use small_snake_case? Or actually we just directly let the user choose (since the naming does not matter expansion)