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

Method GetHandler

protocol/http/http_server.go:69–86  ·  view source on GitHub ↗

GetHandler 支持http进行Get

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

Source from the content-addressed store, hash-verified

67
68// GetHandler 支持http进行Get
69func (hs *HttpHandler) GetHandler(w http.ResponseWriter, r *http.Request) {
70 key := r.FormValue("key")
71 if key == "" {
72 http.Error(w, "key is empty", http.StatusBadRequest)
73 return
74 }
75
76 val, err := hs.Get([]byte(key))
77 if err != nil {
78 http.Error(w, err.Error(), http.StatusInternalServerError)
79 return
80 }
81
82 _, err = w.Write(val)
83 if err != nil {
84 return
85 }
86}
87
88// PostHandler 支持http进行Post
89func (hs *HttpHandler) PostHandler(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 2

GetMethod · 0.65
WriteMethod · 0.65

Tested by

no test coverage detected