turbo has a wide range of functionalities inbuilt which you can leverage to improve your application development.
Once you have created the object of turbo
An instance of turbo is created which is used as an handler to the http.Server object below
Multiple configurations can be done on the http.Server object above based on the requirements and specifications. Some of the configurations that you can provide are TLSConfig, IdleTimeout, ReadHeaderTimeout etc. More information regarding the http.Server object can be found in the documentation.
Now that the server has been configured, API routes need to be registered to the server in order to process those requests.
There are multiple ways with which we can add routes to our server handler.
- Adding routes based on different HTTP Methods
- Multiple HTTP Methods Registering
Adding routes based on different HTTP Methods
turbo supports all the basic HTTP methods needed to build an application, and you can follow the below ways on how to register a particular route
Any route that gets added using below format, contains 2 parameters
- the path of the API
- the handler which processes the request
- Add a GET route
- Add a POST route
- Add a PUT route
- Add a DELETE route
Multiple HTTP Methods Registering
Router lets you register same handler with multiple methods such as ("POST", "PUT") for a single endpoint. With the help of Add function that can be achieved
Contributing
- To contribute to samples, please follow the Repository
- Any suggestions to improve the library are welcomed, we want this to be a community driven project and help it grow.
- If you feel any improvements in the package, feel free to raise the PR - Project
- If you find any bugs that we may have missed, feel free to raise the issues - Raise an Issue
- Looking forward to your contributions..
Project Details
Repository : golly-samples
This was an in-depth description of different ways you can register routes in turbo.
We will be discussing how to read query params, path params and adding filters to the turbo in the next post.
Stay Tuned!!🕵🏻♂️
And if you have any questions, I am happy to answer🚀