fix(example plugin): update PermittedAPIEndpoints

This commit is contained in:
Anthony Rubick
2025-07-19 22:50:42 -07:00
parent 40f915f7fb
commit ad2519d894
2 changed files with 11 additions and 7 deletions

View File

@@ -32,7 +32,7 @@ func main() {
PermittedAPIEndpoints: []plugin.PermittedAPIEndpoint{
{
Method: http.MethodGet,
Endpoint: "/api/access/list",
Endpoint: "/plugin/api/access/list",
Reason: "Used to display all configured Access Rules",
},
},

View File

@@ -28,17 +28,17 @@ func allowedEndpoint(cfg *plugin.ConfigureSpec) (string, error) {
}
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)
if err != nil {
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
}
@@ -126,7 +126,11 @@ func RenderUI(config *plugin.ConfigureSpec, w http.ResponseWriter, r *http.Reque
accessList, err := allowedEndpoint(config)
var RenderedAccessListHTML string
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 {
// Render the access list as HTML
RenderedAccessListHTML = fmt.Sprintf("<pre>%s</pre>", html.EscapeString(accessList))