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

quark.ServerResponder Maven / Gradle / Ivy

There is a newer version: 2.0.37
Show newest version
/* Quark 1.0.452 run at 2016-11-11 16:09:46.008093 */
package quark;

public class ServerResponder implements quark.concurrent.FutureListener, io.datawire.quark.runtime.QObject {
    public static quark.reflect.Class quark_ServerResponder_ref = datawire_mdk_md.Root.quark_ServerResponder_md;
    public Boolean sendCORS;
    public HTTPRequest request;
    public HTTPResponse response;
    public ServerResponder(Boolean sendCORS, HTTPRequest request, HTTPResponse response) {
        (this).sendCORS = sendCORS;
        (this).request = request;
        (this).response = response;
    }
    public void onFuture(quark.concurrent.Future result) {
        quark.error.Error error = (result).getError();
        if (!((error)==(null) || ((Object)(error) != null && ((Object) (error)).equals(null)))) {
            (this.response).setCode(404);
        } else {
            if ((this).sendCORS) {
                ((this).response).setHeader("Access-Control-Allow-Origin", "*");
            }
            ((this).response).setBody((Functions.toJSON(result, null)).toString());
            ((this).response).setCode(200);
        }
        (quark.concurrent.Context.runtime()).respond(this.request, this.response);
    }
    public String _getClass() {
        return "quark.ServerResponder";
    }
    public Object _getField(String name) {
        if ((name)==("sendCORS") || ((Object)(name) != null && ((Object) (name)).equals("sendCORS"))) {
            return (this).sendCORS;
        }
        if ((name)==("request") || ((Object)(name) != null && ((Object) (name)).equals("request"))) {
            return (this).request;
        }
        if ((name)==("response") || ((Object)(name) != null && ((Object) (name)).equals("response"))) {
            return (this).response;
        }
        return null;
    }
    public void _setField(String name, Object value) {
        if ((name)==("sendCORS") || ((Object)(name) != null && ((Object) (name)).equals("sendCORS"))) {
            (this).sendCORS = (Boolean) (value);
        }
        if ((name)==("request") || ((Object)(name) != null && ((Object) (name)).equals("request"))) {
            (this).request = (HTTPRequest) (value);
        }
        if ((name)==("response") || ((Object)(name) != null && ((Object) (name)).equals("response"))) {
            (this).response = (HTTPResponse) (value);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy