Practice in creating endpoint
Now it's time to create your own endpoint! In the last module, we have already created our own business process, but so far, we have not had the opportunity to try it out in practice. Now we will do it.
In order to do this, it is best to create a separate group of endpoints by pressing the New Group button. Let's call it AppMaster Course and add a new endpoint to it.
The necessary settings are visible in the screenshot and should not be difficult. You need to select a method (it is logical to use GET), set the URL (module4-basic is an example, but you can specify any other), and select the required business process (it was created in the 4th module and called Basic functions).
On the Middleware tab, you can immediately disable Token Auth (it is enabled by default) and open access to this endpoint without restricting it to authorized users.
This completes the creation of the endpoint. You can publish the application and use it! It remains only to figure out how to use it.
It is possible to do this in the same way as in the first module, using the command line. Or, as in the second module, through the capabilities of the External API Request. However, both of these options can not be called the most convenient.
AppMaster has a more convenient tool called Swagger, which we'll be using.
What is Swagger? In short, this is a set of tools for creating interactive documentation. In the future, we will have the opportunity to study it in more detail. And at the current stage, it is enough to understand that Swagger makes it possible to see all the endpoints of our application, study their request parameters, and see the expected response. And most importantly, it makes it possible to execute any request and get the result quickly.
To open it, click the Preview button and select Development in the Project API section (Don't forget to publish the app!)
In the open browser tab, we have to find the created endpoint. Click on the Try it out button, enter the required data, and send the request by clicking the Execute button.
If everything is done correctly, the result will match the screenshot. The answer shows the result of mathematical operations with X and Y (addition, subtraction, multiplication, division, and one more division, but already rounded to the first decimal place).
In the next module, we will analyze the creation of the frontend, and we will create a web application, and make our own convenient admin panel.