MCPcopy Create free account
hub / github.com/akash-network/provider / NewOperatorHTTP

Function NewOperatorHTTP

operator/common/operator_server.go:32–62  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30}
31
32func NewOperatorHTTP() (OperatorHTTP, error) {
33 retval := &operatorHTTP{
34 router: mux.NewRouter(),
35 results: make(map[string]preparedEntry),
36 }
37
38 retval.router.HandleFunc("/health", func(rw http.ResponseWriter, _ *http.Request) {
39 rw.WriteHeader(http.StatusOK)
40 _, _ = io.WriteString(rw, "OK")
41 })
42
43 akashVersion := version.NewInfo()
44 buf := &bytes.Buffer{}
45 enc := json.NewEncoder(buf)
46 err := enc.Encode(akashVersion)
47
48 if err != nil {
49 return nil, err
50 }
51
52 akashVersionJSON := buf.Bytes()
53 buf = nil // remove from scope
54 enc = nil // remove from scope
55
56 retval.router.HandleFunc("/version", func(rw http.ResponseWriter, _ *http.Request) {
57 rw.WriteHeader(http.StatusOK)
58 _, _ = io.Copy(rw, bytes.NewReader(akashVersionJSON))
59 }).Methods("GET")
60
61 return retval, nil
62}
63
64func (opHttp *operatorHTTP) GetRouter() *mux.Router {
65 return opHttp.router

Callers 5

newHostnameOperatorFunction · 0.92
newIPOperatorFunction · 0.92
TestOperatorServerFunction · 0.85

Calls 2

NewInfoFunction · 0.92
CopyMethod · 0.45