(w http.ResponseWriter, r *http.Request)
| 157 | } |
| 158 | |
| 159 | func memoryLimitPutHandler(w http.ResponseWriter, r *http.Request) { |
| 160 | body, err := io.ReadAll(r.Body) |
| 161 | if err != nil { |
| 162 | http.Error(w, err.Error(), http.StatusInternalServerError) |
| 163 | return |
| 164 | } |
| 165 | memoryMB, err := strconv.ParseFloat(string(body), 64) |
| 166 | if err != nil { |
| 167 | http.Error(w, err.Error(), http.StatusBadRequest) |
| 168 | return |
| 169 | } |
| 170 | gqlReq := &schema.Request{ |
| 171 | Query: ` |
| 172 | mutation config($cacheMb: Float) { |
| 173 | config(input: {cacheMb: $cacheMb}) { |
| 174 | response { |
| 175 | code |
| 176 | } |
| 177 | } |
| 178 | }`, |
| 179 | Variables: map[string]interface{}{"cacheMb": memoryMB}, |
| 180 | } |
| 181 | resp := resolveWithAdminServer(gqlReq, r, adminServer) |
| 182 | |
| 183 | if len(resp.Errors) != 0 { |
| 184 | w.WriteHeader(http.StatusBadRequest) |
| 185 | x.Check2(fmt.Fprint(w, resp.Errors[0].Message)) |
| 186 | return |
| 187 | } |
| 188 | w.WriteHeader(http.StatusOK) |
| 189 | } |
| 190 | |
| 191 | func memoryLimitGetHandler(w http.ResponseWriter, r *http.Request) { |
| 192 | gqlReq := &schema.Request{ |
no test coverage detected