MCPcopy
hub / github.com/jhaals/yopass / jsonError

Function jsonError

pkg/server/server.go:91–97  ·  view source on GitHub ↗

jsonError writes a {"message": ...} error body with the given status code and a correct application/json content type.

(w http.ResponseWriter, code int, message string)

Source from the content-addressed store, hash-verified

89// jsonError writes a {"message": ...} error body with the given status code
90// and a correct application/json content type.
91func jsonError(w http.ResponseWriter, code int, message string) {
92 w.Header().Set("Content-Type", "application/json")
93 w.WriteHeader(code)
94 if err := json.NewEncoder(w).Encode(map[string]string{"message": message}); err != nil {
95 zap.L().Error("Failed to write error response", zap.Error(err))
96 }
97}
98
99// authorizeSecretAccess enforces RequireAuth for secret retrieval and
100// deletion. It writes the error response and audit event itself and reports

Callers 15

authorizeSecretAccessMethod · 0.85
claimOneTimeSecretMethod · 0.85
createSecretMethod · 0.85
getSecretMethod · 0.85
getSecretStatusMethod · 0.85
deleteSecretMethod · 0.85
streamUploadMethod · 0.85
streamDownloadMethod · 0.85
deleteStreamSecretMethod · 0.85
getStreamSecretStatusMethod · 0.85
oidcUserinfoCallbackMethod · 0.85
oidcMeHandlerMethod · 0.85

Calls 2

WriteHeaderMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected