mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-25 02:21:05 +01:00
schema update and api /v1/schema
This commit is contained in:
@@ -37,6 +37,7 @@ func NewHandler() http.Handler {
|
||||
mux.HandleFunc("PUT", "/v1/file/{filename...}", auth.RequireAuth(v1.SetFileContent))
|
||||
mux.HandleFunc("GET", "/v1/stats", v1.Stats)
|
||||
mux.HandleFunc("GET", "/v1/stats/ws", v1.StatsWS)
|
||||
mux.HandleFunc("GET", "/v1/schema/{filename...}", v1.GetSchemaFile)
|
||||
return mux
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user