mirror of
https://github.com/yusing/godoxy.git
synced 2025-07-16 18:24:02 +02:00
schema update and api /v1/schema
This commit is contained in:
parent
6034908a95
commit
29f85db022
4 changed files with 29 additions and 16 deletions
|
@ -50,6 +50,9 @@ COPY config.example.yml /app/config/config.yml
|
||||||
# copy certs
|
# copy certs
|
||||||
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
|
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
|
||||||
|
|
||||||
|
# copy schema
|
||||||
|
COPY schema /app/schema
|
||||||
|
|
||||||
ENV DOCKER_HOST=unix:///var/run/docker.sock
|
ENV DOCKER_HOST=unix:///var/run/docker.sock
|
||||||
ENV GODOXY_DEBUG=0
|
ENV GODOXY_DEBUG=0
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ func NewHandler() http.Handler {
|
||||||
mux.HandleFunc("PUT", "/v1/file/{filename...}", auth.RequireAuth(v1.SetFileContent))
|
mux.HandleFunc("PUT", "/v1/file/{filename...}", auth.RequireAuth(v1.SetFileContent))
|
||||||
mux.HandleFunc("GET", "/v1/stats", v1.Stats)
|
mux.HandleFunc("GET", "/v1/stats", v1.Stats)
|
||||||
mux.HandleFunc("GET", "/v1/stats/ws", v1.StatsWS)
|
mux.HandleFunc("GET", "/v1/stats/ws", v1.StatsWS)
|
||||||
|
mux.HandleFunc("GET", "/v1/schema/{filename...}", v1.GetSchemaFile)
|
||||||
return mux
|
return mux
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,3 +64,16 @@ func SetFileContent(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusOK)
|
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)
|
||||||
|
}
|
||||||
|
|
|
@ -121,6 +121,7 @@
|
||||||
},
|
},
|
||||||
"load_balance": {
|
"load_balance": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"additionalProperties": false,
|
||||||
"properties": {
|
"properties": {
|
||||||
"link": {
|
"link": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -149,6 +150,7 @@
|
||||||
},
|
},
|
||||||
"healthcheck": {
|
"healthcheck": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"additionalProperties": false,
|
||||||
"properties": {
|
"properties": {
|
||||||
"disable": {
|
"disable": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
@ -203,7 +205,8 @@
|
||||||
"then": {
|
"then": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"port": {
|
"port": {
|
||||||
"markdownDescription": "Proxy port from **0** to **65535**",
|
"title": "Proxy port",
|
||||||
|
"markdownDescription": "From **0** to **65535**",
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -218,22 +221,15 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"path_patterns": {
|
"path_patterns": {
|
||||||
"oneOf": [
|
"title": "Path patterns",
|
||||||
{
|
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"markdownDescription": "A list of [path patterns](https://pkg.go.dev/net/http#hdr-Patterns-ServeMux)",
|
"markdownDescription": "See https://pkg.go.dev/net/http#hdr-Patterns-ServeMux",
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"pattern": "^(?:([A-Z]+) )?(?:([a-zA-Z0-9.-]+)\\/)?(\\/[^\\s]*)$",
|
"pattern": "^(?:([A-Z]+) )?(?:([a-zA-Z0-9.-]+)\\/)?(\\/[^\\s]*)$",
|
||||||
"patternErrorMessage": "invalid path pattern"
|
"patternErrorMessage": "invalid path pattern"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "null",
|
|
||||||
"description": "No proxy path"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"middlewares": {
|
"middlewares": {
|
||||||
"type": "object"
|
"type": "object"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue