With data_tables in acceptance.json, a public route over a site data table fails check 33 only when the table read holds a personal field by the spec or the classifier. The table is resolved from a literal GetTableByKey key; an unresolved read falls back to any declared table being personal. Without data_tables every read stays personal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
1015 B
Go
42 lines
1015 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"git.dev.alexdunmow.com/block/pluginsdk/plugin"
|
|
"git.dev.alexdunmow.com/block/pluginsdk/route"
|
|
)
|
|
|
|
const pluginName = "newsletter-9a0b11"
|
|
|
|
// Registration is the plugin entry registration.
|
|
var Registration = plugin.PluginRegistration{
|
|
Name: pluginName,
|
|
Version: "1.0.0",
|
|
HTTPHandler: newHTTPHandler,
|
|
}
|
|
|
|
var current plugin.CoreServices
|
|
|
|
func newHTTPHandler(deps plugin.CoreServices) http.Handler {
|
|
current = deps
|
|
r := route.New(pluginName)
|
|
r.Handle(http.MethodGet, "/subscribers", route.Public, handleList)
|
|
return r
|
|
}
|
|
|
|
func handleList(w http.ResponseWriter, r *http.Request) {
|
|
table, err := current.DataTables.GetTableByKey(r.Context(), "subscribers")
|
|
if err != nil {
|
|
http.Error(w, "not found", http.StatusNotFound)
|
|
return
|
|
}
|
|
rows, err := current.DataTables.ListRows(r.Context(), table.ID, 100, 0)
|
|
if err != nil {
|
|
http.Error(w, "could not load rows", http.StatusInternalServerError)
|
|
return
|
|
}
|
|
_ = json.NewEncoder(w).Encode(rows)
|
|
}
|