public void serveDescription(RestServiceRequest rsr) { rsr.startDoc(); if (rsr.getResponseContentType() == ResponseType.HTML) rsr.write("<h1>Operation: ").write(getRelativeUrl()).write("</h1>"); rsr.datawriter .object() .key("name") .value(getRelativeUrl()) .key("description") .value(description) .key("url") .value(RestServices.getAbsoluteUrl(getRelativeUrl())) .key("arguments") .value( hasArgument ? JSONSchemaBuilder.build(Utils.getFirstArgumentType(microflowname)) : null) .key("accepts_binary_data") .value(isFileSource) .key("result") .value( isFileTarget ? RestServices.CONTENTTYPE_OCTET + " stream" : JSONSchemaBuilder.build(Core.getReturnType(microflowname))) .endObject(); rsr.endDoc(); }
public static void serveServiceOverview(RestServiceRequest rsr) { rsr.startDoc(); if (rsr.getResponseContentType() == ResponseType.HTML) rsr.write("<h1>RestServices</h1>"); rsr.datawriter.object().key("RestServices").value(RestServices.VERSION).key("services").array(); for (String service : RestServiceHandler.getServiceBaseUrls()) rsr.datawriter.value(RestServices.getAbsoluteUrl(service) + "?" + RestServices.PARAM_ABOUT); rsr.datawriter.endArray().endObject(); rsr.endDoc(); }
public ServiceDescriber(RestServiceRequest rsr, DataServiceDefinition def) { this.rsr = rsr; this.def = def; this.isHTML = rsr.getResponseContentType() == ResponseType.HTML; }