MCPcopy
hub / github.com/bettercap/bettercap / Start

Method Start

modules/api_rest/api_rest.go:270–294  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

268}
269
270func (mod *RestAPI) Start() error {
271 if mod.replaying {
272 return fmt.Errorf("the api is currently in replay mode, run api.rest.replay off before starting it")
273 } else if err := mod.Configure(); err != nil {
274 return err
275 }
276
277 mod.SetRunning(true, func() {
278 var err error
279
280 if mod.isTLS() {
281 mod.Info("api server starting on https://%s", mod.server.Addr)
282 err = mod.server.ListenAndServeTLS(mod.certFile, mod.keyFile)
283 } else {
284 mod.Info("api server starting on http://%s", mod.server.Addr)
285 err = mod.server.ListenAndServe()
286 }
287
288 if err != nil && err != http.ErrServerClosed {
289 panic(err)
290 }
291 })
292
293 return nil
294}
295
296func (mod *RestAPI) Stop() error {
297 if mod.recording {

Callers 4

startRecordingMethod · 0.95
NewRestAPIFunction · 0.95
startReplayMethod · 0.95
TestStartErrorsFunction · 0.95

Calls 4

ConfigureMethod · 0.95
isTLSMethod · 0.95
SetRunningMethod · 0.80
InfoMethod · 0.45

Tested by 1

TestStartErrorsFunction · 0.76