mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 04:42:33 +02:00

* use auto generated schemas * go version bump and dependencies upgrade * clarify some error messages --------- Co-authored-by: yusing <yusing@6uo.me>
23 lines
500 B
Go
23 lines
500 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.SchemasBasePath, filename))
|
|
if err != nil {
|
|
U.HandleErr(w, r, err)
|
|
return
|
|
}
|
|
U.WriteBody(w, content)
|
|
}
|