All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.tsl2.nano.h5.RestUI Maven / Gradle / Ivy

Go to download

TSL2 Framework Html5 Extensions (WebServer, Html5Presentation, RuleCover, BeanConfigurator, LogicTable-Sheet, Expression-Descriptors for Actions, Rules, URLs, Queries)

There is a newer version: 2.5.2
Show newest version
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);
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy