The generation of controllers actions is now very rude:
- Http Method: if the method has no arguments,I assume GET . Else it is POST
- How I can handle pure full REST API generation ?
- How I can handle level 3 REST API – https://martinfowler.com/articles/richardsonMaturityModel.html ?
- How I can handle any other models,like https://blog.ploeh.dk/2020/10/26/fit-urls/
- What is generated in the Action Body is hard-coded. What if the user wants something special ?
- The answer from the Action is hardcoded to the answer that the method returns. What if we want something different ?
So some customization should be involved. I need
- a template engine – I choose https://github.com/lunet-io/scriban,to make a change from Razor Pages
- a decision – choose a template for each action. This should / could be implemented by the programmer – as is the person who knows best how to do generate from his actions. However,this should be implemented .
So,first question : how the programmer specifies the decision ( and this decision could be different for each class / field instance) ? This is quite a problem. The programmer should make either a simple decision for their public functions ( like REST API ),either a complicated one – like for doing HttpGet[{id}] or Level 3 REST API ( read above). So,basic,the programmer should indicate a function that depends on
- Name of the public method
- Return Type
- Parameters of the function
and return different template. The template is taking as parameters the same things – and return how the Action will look like.
And now I have seen the light . The function and the template are taking the same arguments. And what is great in programming are pointers. So,the light version of pointers in this case is an enum . I will use an enum,put into https://www.nuget.org/packages/SkinnyControllersCommon/,in order to indicate the template,
The programmer will improve SkinnyControllersCommon with a new enum and a new template,put a PR,and voila! – new version of template for all programmers!
The implementation next time
Leave a Reply