MCPcopy
hub / github.com/OpenNHP/opennhp / loadHttpConfig

Method loadHttpConfig

endpoints/server/config.go:125–152  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

123}
124
125func (s *UdpServer) loadHttpConfig() error {
126 // http.toml
127 fileName := filepath.Join(ExeDirPath, "etc", "http.toml")
128 content, err := s.loadConfigFile(fileName)
129 if err != nil {
130 log.Error("load http config err: %v", err)
131 return err
132 }
133 var httpConf HttpConfig
134 if err := toml.Unmarshal(content, &httpConf); err != nil {
135 log.Error("failed to unmarshal http config: %v", err)
136 }
137 if err = s.updateHttpConfig(httpConf); err != nil {
138 // ignore error
139 _ = err
140 }
141
142 httpConfigWatch = utils.WatchFile(fileName, func() {
143 log.Info("http config: %s has been updated", fileName)
144 if content, err = s.loadConfigFile(fileName); err == nil {
145 if err = toml.Unmarshal(content, &httpConf); err == nil {
146 _ = s.updateHttpConfig(httpConf)
147 }
148 }
149
150 })
151 return nil
152}
153
154func (s *UdpServer) loadPeers() error {
155 // ac.toml

Callers 1

StartMethod · 0.95

Calls 3

loadConfigFileMethod · 0.95
updateHttpConfigMethod · 0.95
ErrorMethod · 0.65

Tested by

no test coverage detected