mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-08-06 05:08:28 +02:00
fix(example plugin): update PermittedAPIEndpoints
This commit is contained in:
@@ -32,7 +32,7 @@ func main() {
|
|||||||
PermittedAPIEndpoints: []plugin.PermittedAPIEndpoint{
|
PermittedAPIEndpoints: []plugin.PermittedAPIEndpoint{
|
||||||
{
|
{
|
||||||
Method: http.MethodGet,
|
Method: http.MethodGet,
|
||||||
Endpoint: "/api/access/list",
|
Endpoint: "/plugin/api/access/list",
|
||||||
Reason: "Used to display all configured Access Rules",
|
Reason: "Used to display all configured Access Rules",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@@ -28,17 +28,17 @@ func allowedEndpoint(cfg *plugin.ConfigureSpec) (string, error) {
|
|||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
// Check if the response status is OK
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
|
||||||
return "", fmt.Errorf("received non-OK response status %d", resp.StatusCode)
|
|
||||||
}
|
|
||||||
|
|
||||||
respDump, err := httputil.DumpResponse(resp, true)
|
respDump, err := httputil.DumpResponse(resp, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
return "", fmt.Errorf("error dumping response: %v", err)
|
return "", fmt.Errorf("error dumping response: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the response status is OK
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
return string(respDump), fmt.Errorf("received non-OK response status %d", resp.StatusCode)
|
||||||
|
}
|
||||||
|
|
||||||
return string(respDump), nil
|
return string(respDump), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +126,11 @@ func RenderUI(config *plugin.ConfigureSpec, w http.ResponseWriter, r *http.Reque
|
|||||||
accessList, err := allowedEndpoint(config)
|
accessList, err := allowedEndpoint(config)
|
||||||
var RenderedAccessListHTML string
|
var RenderedAccessListHTML string
|
||||||
if err != nil {
|
if err != nil {
|
||||||
RenderedAccessListHTML = fmt.Sprintf("<p>Error fetching access list: %v</p>", err)
|
if accessList != "" {
|
||||||
|
RenderedAccessListHTML = fmt.Sprintf("<p>Error fetching access list: %v</p><pre>%s</pre>", err, html.EscapeString(accessList))
|
||||||
|
} else {
|
||||||
|
RenderedAccessListHTML = fmt.Sprintf("<p>Error fetching access list: %v</p>", err)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Render the access list as HTML
|
// Render the access list as HTML
|
||||||
RenderedAccessListHTML = fmt.Sprintf("<pre>%s</pre>", html.EscapeString(accessList))
|
RenderedAccessListHTML = fmt.Sprintf("<pre>%s</pre>", html.EscapeString(accessList))
|
||||||
|
Reference in New Issue
Block a user