de.tsl2.nano.h5.RestUI Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tsl2.nano.h5 Show documentation
Show all versions of tsl2.nano.h5 Show documentation
TSL2 Framework Html5 Extensions (WebServer, Html5Presentation, RuleCover, BeanConfigurator, LogicTable-Sheet, Expression-Descriptors for Actions, Rules, URLs, Queries)
package de.tsl2.nano.h5;
import java.util.Arrays;
import java.util.Map;
import de.tsl2.nano.core.util.StringUtil;
import de.tsl2.nano.h5.ARESTDynamic.Status;
import de.tsl2.nano.h5.NanoHTTPD.Response;
public class RestUI extends ARestUI {
@Override
protected Response createResponse(Status status, String mimeType, String html) {
return new RESTDynamic().createResponse(status, mimeType, html);
}
@Override
protected Status getStatus(Response restResponse) {
return Arrays.stream(Status.values()).filter(s -> restResponse.getStatus().getRequestStatus() == s.http()).findFirst().get();
}
@Override
protected String getData(Response restResponse) {
return StringUtil.fromInputStream(restResponse.getData(), "\n");
}
@Override
protected Response callRestService(String url, String method, Map header, Map parms,
Map payload) {
return new RESTDynamic().serve(restUrl(url), method, header, parms, payload, true);
}
}