schema update and api /v1/schema

This commit is contained in:
yusing
2025-01-06 00:49:29 +08:00
parent 6034908a95
commit 29f85db022
4 changed files with 29 additions and 16 deletions

View File

@@ -64,3 +64,16 @@ func SetFileContent(w http.ResponseWriter, r *http.Request) {
}
w.WriteHeader(http.StatusOK)
}
func GetSchemaFile(w http.ResponseWriter, r *http.Request) {
filename := r.PathValue("filename")
if filename == "" {
U.RespondError(w, U.ErrMissingKey("filename"), http.StatusBadRequest)
}
content, err := os.ReadFile(path.Join(common.SchemaBasePath, filename))
if err != nil {
U.HandleErr(w, r, err)
return
}
U.WriteBody(w, content)
}