API Server Generic API Server

This article has studied the source code of the Generic API Server part, equipped with the source code for further understanding, which can deepen the understanding and enhance related design capabilities.

Delegation Chain

Overview

Server Chain

HTTP Server

Handler Chain

The type of HandlerChainBuilderFn is defined as follows. Pass in an http.Handler instance and return an http.Handler instance. In this way, a middleware-like effect can be achieved.

When creating the ApiServerHandler, use the following method.

Start

The final startup code of preparedAPIAggregator is as follows. It simply calls the Run method of runnable. In Server Chain, we know that runnable is an instance of preparedGenericAPIServer generated by GenericAPIServer included in APIAggregator.

The Run method of PreparedGenericapiServer is as follows.

Last updated