36 lines
685 B
Go
36 lines
685 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"inou/lib"
|
|
)
|
|
|
|
func handleDossiers(w http.ResponseWriter, r *http.Request) {
|
|
ctx := getAccessContextOrFail(w, r)
|
|
if ctx == nil {
|
|
return
|
|
}
|
|
|
|
LogMCPConnect(ctx.AccessorID)
|
|
|
|
// Use RBAC-aware function that returns only accessible dossiers
|
|
dossiers, err := lib.DossierQuery(ctx.AccessorID)
|
|
if err != nil {
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
|
|
var result []map[string]string
|
|
for _, d := range dossiers {
|
|
result = append(result, map[string]string{
|
|
"id": d.DossierID,
|
|
"name": d.Name,
|
|
})
|
|
}
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
json.NewEncoder(w).Encode(result)
|
|
}
|