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
router.Get("api/v1/users", getUsers)
Add a POST route
router.Post("api/v1/users", addUser)
Add a PUT route
router.Put("api/v1/users/:id", updateUser)
Add a DELETE route
router.Delete("api/v1/users/:id", deleteUser)
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
Welcome to the Golly Examples Repository! This repository contains a collection of sample code snippets and examples from the individual libraries of the Golly project. Each example is designed to demonstrate the usage and capabilities of different modules within the Golly ecosystem.
Golly is an open-source project aimed at providing robust tools and libraries for various applications. This repository showcases practical examples to help developers understand and utilize the different components of Golly effectively.
Getting Started
To get started with the examples, you'll need to have Golly installed. You can follow the instructions on the Golly GitHub page to set it up.
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🚀