AutoActions for Skinny controllers–user customization

The generation of controllers actions is now very rude:

  1. Http Method: if the method has no arguments, I assume GET . Else it is POST
  2. What is generated in the Action Body is hard-coded. What if the user wants something special ?
  3. 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

  1. a template engine – I choose https://github.com/lunet-io/scriban , to make a change from Razor Pages
  2. 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

  1. Name of the public method
  2. Return Type
  3. 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