mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 12:42:34 +02:00
23 lines
499 B
Go
23 lines
499 B
Go
package v1
|
|
|
|
import (
|
|
"net/http"
|
|
"os"
|
|
"path"
|
|
|
|
U "github.com/yusing/go-proxy/internal/api/v1/utils"
|
|
"github.com/yusing/go-proxy/internal/common"
|
|
)
|
|
|
|
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)
|
|
}
|