MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / NewHTTPAdapter

Function NewHTTPAdapter

sqlchain/adapter/server.go:37–64  ·  view source on GitHub ↗

NewHTTPAdapter creates adapter to service.

(listenAddr string, configFile string, adapterUseMirrorAddr string)

Source from the content-addressed store, hash-verified

35
36// NewHTTPAdapter creates adapter to service.
37func NewHTTPAdapter(listenAddr string, configFile string, adapterUseMirrorAddr string) (adapter *HTTPAdapter, err error) {
38 adapter = new(HTTPAdapter)
39
40 // load config file
41 var cfg *config.Config
42 if cfg, err = config.LoadConfig(configFile); err != nil {
43 return
44 }
45
46 if listenAddr != "" {
47 cfg.ListenAddr = listenAddr
48 }
49 if adapterUseMirrorAddr != "" {
50 cfg.MirrorServer = adapterUseMirrorAddr
51 }
52 // init server
53 handler := handlers.CORS(
54 handlers.AllowedHeaders([]string{"Content-Type"}),
55 )(api.GetRouter())
56
57 adapter.server = &http.Server{
58 TLSConfig: cfg.TLSConfig,
59 Addr: cfg.ListenAddr,
60 Handler: handler,
61 }
62
63 return
64}
65
66// Serve defines adapter serve logic.
67func (adapter *HTTPAdapter) Serve() (err error) {

Callers 1

startAdapterServerFunction · 0.92

Calls 2

LoadConfigFunction · 0.92
GetRouterFunction · 0.92

Tested by

no test coverage detected