Root / Assembly / ARCAPI / Class / BaseController
|_Member||APIMethod, BuildControllerStorage, CatchAll, GetFormatAndAdjustRequest, ToString, TryNavigateToLevelInDataStorage|
|Description||Contains basic functionality for serving API methods.|
The specific controller instances serving requests are usually stored in a global DataStorage.
For instance for an API node with id 'API/1/' it would typically be stored as 'API/1/Controller/api/[TypeOfController]/[ControllerId]...'.
(in other words, ControllerStorage actually points to a branch inside Storage.)
Examples of API requests and how they are resolved to a container by CatchAll:
API request URL: https://yourserver.com/api/RQ/std/Customer/42/.html
Controller instance (in this case of type RQController) to be found in controllerStorage["api"]["RQ"]["std"]
Method APIMethod is called on this instance.
This system has the following advantages:
1) The API-routing syntax is by default exposed to the outside because 'controller storage' is normally inserted into the global DataStorage.
Therefore the standard query mechanism in AgoRapide can be used to get this information.
For instance by querying like this: 'api/RQ/API/1/Controller' you will get suggestions starting with the 'api'.
2) The API itself is discoverable even without querying like above, without much special code.
This is because an invalid API request is actually analyzed by the same mechanism answering standard queries.
When the error message is returned it actually contains data about the correct syntax.
3) The API is configurable both through the API itself and also over the PropertyStream.
For instance like 'API/1/Controller/RQ/std/LogLevel = Warning' which would change the log level for the standard instance ('std') of RQController to 'Warning'.
4) Different instances of the same controller type can exist and be configured individually. For instance if some specific query needs additional logging down to debug level, a dedicated controller can be created for this, like
'API/1/Controller/RQ/dbg/LogLevel = Debug'
This controller instance will be immediately available as request 'api/RQ/dbg/[Parameters]'
Note that a 'dbg' controller is always available, which does detailed logging.
Some limitations of this approach are:
1) Actual API method name is limited to the name of the controller type (without the 'Controller' part).
That is, a controller called CustomerController can only serve queries starting with 'Customer'.
Note however that in your ApplicationSpecificCode you can implement any additional controllers with routing structure totally independent of this standard generic AgoRapide mechanism.
Note how the BaseController classes (like this class) do not inherit any special Microsoft.AspNetCore.Mvc class.
They are totally stand-alone with regard to Microsoft.AspNetCore.Mvc.
|Interfaces||ARCCore.IP; -System.Collections.Generic.IEnumerable`1[ARCCore.IKIP]-; -System.Collections.IEnumerable-|
Generated 2020-10-13 11:11:00.728 UTC