MCPcopy Create free account
hub / github.com/ByteStorage/FlyDB / GetListKeysHandler

Method GetListKeysHandler

protocol/http/http_server.go:132–152  ·  view source on GitHub ↗

GetListKeysHandler 支持http获取数据库中所有键

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

130
131// GetListKeysHandler 支持http获取数据库中所有键
132func (hs *HttpHandler) GetListKeysHandler(w http.ResponseWriter, r *http.Request) {
133 keys := hs.GetListKeys()
134 if keys == nil {
135 http.Error(w, "key is empty", http.StatusBadRequest)
136 return
137 }
138 jsonKeys, err := json.Marshal(keys)
139 if err != nil {
140 // Handle the error
141 http.Error(w, "Internal Server Error", http.StatusInternalServerError)
142 return
143 }
144
145 // Write the JSON response
146 _, err = w.Write(jsonKeys)
147 if err != nil {
148 // 处理写入响应失败的错误
149 http.Error(w, err.Error(), http.StatusInternalServerError)
150 return
151 }
152}

Callers

nothing calls this directly

Calls 2

GetListKeysMethod · 0.80
WriteMethod · 0.65

Tested by

no test coverage detected