Web service processing phases
In Granitic, the components and processes that are used to service an HTTP request to your application are organised into a series of ‘phases’. Although the order of these phases is fixed, most of them can be customised, disabled or even swapped out for your own implementation.
A request is initially handled by Granitic’s HTTP server facility then passed on to a component that implements httpendpoint.Provider and supports the incoming request’s URL and HTTP method. In the vast majority of cases that component will be an instance of Granitic’s built-in handler.WsHandler.
Your application will associate a logic component with each handler to perform business logice and build a response.
|HTTP Server||Instrumentation||Begin timing/metric gathering if your application supports instrumentation|
|Load management||Reject request if too busy/suspended|
|Request identification||Assign a unique ID to the request if supported by your application|
|Matching||Attempt to match the request’s path and HTTP method to a handler|
|Version routing||If your application supports version routing the correct handler for the request version is found|
|Handler||Authentication||If your application supports identity and access management the request caller is authenticated|
|Authorisation||If the caller has been authenticated, their permission to access this functionality is checked|
|Data extraction||Data from the request body, path and query parameters is parsed into a struct|
|Validation||The extracted data is validated to confirm that it is ready to be processed|
|Application logic||Processing||The application logic component performs the actual function of the web service|
|Response construction||A Go struct is populated with data that will form the response to the request|
|Handler||Response serialisation||Serialise the response struct (normally to JSON or XML)|
|HTTP Server||Request finalisation||Instrumentation ended and HTTP request closed|
The above represents the ‘happy path’ for a request. Most of the phases can terminate early triggering automatic error handling
Next: Endpoints and handlers
Prev: Enabling web services