MCPcopy Index your code
hub / github.com/shadow1ng/fscan / Create

Method Create

web/api/project.go:220–238  ·  view source on GitHub ↗

Create 创建项目

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

Source from the content-addressed store, hash-verified

218
219// Create 创建项目
220func (h *ProjectHandler) Create(w http.ResponseWriter, r *http.Request) {
221 if r.Method != http.MethodPost {
222 http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
223 return
224 }
225 var req struct {
226 Name string `json:"name"`
227 }
228 if err := json.NewDecoder(r.Body).Decode(&req); err != nil || req.Name == "" {
229 writeJSON(w, http.StatusBadRequest, map[string]string{"error": "name is required"})
230 return
231 }
232 p, err := h.store.Create(req.Name)
233 if err != nil {
234 writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
235 return
236 }
237 writeJSON(w, http.StatusOK, p)
238}
239
240// Get 获取项目详情
241func (h *ProjectHandler) Get(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 3

writeJSONFunction · 0.85
ErrorMethod · 0.45
CreateMethod · 0.45

Tested by

no test coverage detected