Search in sources :

Example 1 with VirtualUser

use of io.vertx.up.atom.hold.VirtualUser in project vertx-zero by silentbalanceyh.

the class DataEncap method build.

private static Envelop build(final JsonObject json) {
    Envelop envelop = Envelop.ok();
    // 1. Headers
    if (null != json) {
        // 2.Rebuild
        if (json.containsKey("data")) {
            envelop = Envelop.success(json.getValue("data"));
        }
        // 3.Header
        if (null != json.getValue("header")) {
            final MultiMap headers = MultiMap.caseInsensitiveMultiMap();
            final JsonObject headerData = json.getJsonObject("header");
            for (final String key : headerData.fieldNames()) {
                final Object value = headerData.getValue(key);
                if (null != value) {
                    headers.set(key, value.toString());
                }
            }
            envelop.setHeaders(headers);
        }
        // 4.User
        if (null != json.getValue("user")) {
            envelop.setUser(new VirtualUser(json.getJsonObject("user")));
        }
    }
    return envelop;
}
Also used : MultiMap(io.vertx.core.MultiMap) IpcEnvelop(io.vertx.tp.ipc.eon.IpcEnvelop) Envelop(io.vertx.up.atom.Envelop) VirtualUser(io.vertx.up.atom.hold.VirtualUser) JsonObject(io.vertx.core.json.JsonObject) JsonObject(io.vertx.core.json.JsonObject)

Aggregations

MultiMap (io.vertx.core.MultiMap)1 JsonObject (io.vertx.core.json.JsonObject)1 IpcEnvelop (io.vertx.tp.ipc.eon.IpcEnvelop)1 Envelop (io.vertx.up.atom.Envelop)1 VirtualUser (io.vertx.up.atom.hold.VirtualUser)1