Endpoints are used to handle the requests to a Platformus-based web application. You can manage them (add, edit, and delete) from the backend using the :guilabel:`Development/Endpoints` section:
Each endpoint has name, URL template, position, and few other fields:
Name is used only in the endpoint list. URL template is used by the implementation of the IEndpointResolver interface to select the endpoint which should process current request (see below). Position is important, because endpoint resolver checks the endpoints one by one, and it will return the first matching endpoint from the list, sorted by position.
The :guilabel:`Disallow anonymous` checkbox allows you to specify, whether a user must be authenticated in order to be able to get the response from this endpoint. On the :guilabel:`Permissions` tab you can specify which permissions the user must have and where it should be redirected if it doesn’t have any required permission.
The :guilabel:`C# class name` drop down list allows you to specify, which C# class (implementation of the IEndpoint interface) will handle the requests. It is very important, because you can write your own implementations of this interface and handle the requests in any way you want. You can return views, JSON, files, plain text, redirects, or any other content. There is the only one built-in endpoint: the DefaultEndpoint class. It returns views (you can specify the view name) and supports caching.
If we are talking about the views, endpoint should provide any information a view needs using the view model. Endpoint creates and initializes a view model using the data sources. Each endpoint can have different data sources:
Data source is a C# class too. It must implement the IDataSource interface. You can implement this interface in your own classes and return any data you want.
There are few built-in data sources.
PageDataSource loads the object by its
URL property value.
ObjectsDataSource loads the objects of the specified class. Also, it supports filtegin, sorting, and paging.
ForeignObjectsDataSource load the objects that are related to the one,
URL property value matches current request’s URL (these both support filtegin, sorting, and paging too).
Each data source has code and C# class name:
While C# class name is clear for now, code is used as the view model property name. So if you have specified some code, your view model will have a property with this name.