MCPcopy
hub / github.com/bettercap/bettercap / NewHttpServer

Function NewHttpServer

modules/http_server/http_server.go:20–53  ·  view source on GitHub ↗
(s *session.Session)

Source from the content-addressed store, hash-verified

18}
19
20func NewHttpServer(s *session.Session) *HttpServer {
21 mod := &HttpServer{
22 SessionModule: session.NewSessionModule("http.server", s),
23 server: &http.Server{},
24 }
25
26 mod.AddParam(session.NewStringParameter("http.server.path",
27 ".",
28 "",
29 "Server folder."))
30
31 mod.AddParam(session.NewStringParameter("http.server.address",
32 session.ParamIfaceAddress,
33 session.IPv4Validator,
34 "Address to bind the HTTP server to."))
35
36 mod.AddParam(session.NewIntParameter("http.server.port",
37 "80",
38 "Port to bind the HTTP server to."))
39
40 mod.AddHandler(session.NewModuleHandler("http.server on", "",
41 "Start HTTP server.",
42 func(args []string) error {
43 return mod.Start()
44 }))
45
46 mod.AddHandler(session.NewModuleHandler("http.server off", "",
47 "Stop HTTP server.",
48 func(args []string) error {
49 return mod.Stop()
50 }))
51
52 return mod
53}
54
55func (mod *HttpServer) Name() string {
56 return "http.server"

Callers 1

LoadModulesFunction · 0.92

Calls 8

StartMethod · 0.95
StopMethod · 0.95
NewSessionModuleFunction · 0.92
NewStringParameterFunction · 0.92
NewIntParameterFunction · 0.92
NewModuleHandlerFunction · 0.92
AddParamMethod · 0.80
AddHandlerMethod · 0.80

Tested by

no test coverage detected