Class JsonHttpResponse
java.lang.Object
io.jenkins.plugins.interactiveinput.rest.JsonHttpResponse
- All Implemented Interfaces:
org.kohsuke.stapler.HttpResponse
An
HttpResponse that writes a JSON body with an explicit HTTP status code.
All REST responses use this so both success and error payloads are valid JSON (ยง8.6), letting external agents parse errors uniformly instead of receiving Jenkins' HTML error pages.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic JsonHttpResponseConvenience factory for a JSON error envelope:{"error": true, "message": ...}.voidgenerateResponse(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, Object node) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.kohsuke.stapler.HttpResponse
generateResponse
-
Constructor Details
-
JsonHttpResponse
public JsonHttpResponse(int status, @NonNull net.sf.json.JSONObject body)
-
-
Method Details
-
error
Convenience factory for a JSON error envelope:{"error": true, "message": ...}. -
generateResponse
public void generateResponse(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, Object node) throws IOException - Specified by:
generateResponsein interfaceorg.kohsuke.stapler.HttpResponse- Throws:
IOException
-