當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpMethod.GET屬性代碼示例

本文整理匯總了Java中org.eclipse.jetty.http.HttpMethod.GET屬性的典型用法代碼示例。如果您正苦於以下問題:Java HttpMethod.GET屬性的具體用法?Java HttpMethod.GET怎麽用?Java HttpMethod.GET使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.eclipse.jetty.http.HttpMethod的用法示例。


在下文中一共展示了HttpMethod.GET屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getJails

@Endpoint(method = HttpMethod.GET, path = "jail", perm = "jail.list")
public void getJails(IServletData data) {
    Optional<NucleusJailService> optSrv = NucleusAPI.getJailService();
    if (!optSrv.isPresent()) {
        data.sendError(HttpServletResponse.SC_NOT_FOUND, "Nuclues jail service not available");
        return;
    }

    NucleusJailService srv = optSrv.get();

    Optional<List<CachedNamedLocation>> optRes = WebAPIAPI.runOnMain(
            () -> srv.getJails().values().stream().map(CachedNamedLocation::new).collect(Collectors.toList())
    );

    data.addData("ok", optRes.isPresent(), false);
    data.addData("jails", optRes.orElse(null), data.getQueryParam("details").isPresent());
}
 
開發者ID:Valandur,項目名稱:Web-API,代碼行數:17,代碼來源:NucleusServlet.java

示例2: getJail

@Endpoint(method = HttpMethod.GET, path = "jail/:name", perm = "jail.one")
public void getJail(IServletData data, String name) {
    Optional<NucleusJailService> optSrv = NucleusAPI.getJailService();
    if (!optSrv.isPresent()) {
        data.sendError(HttpServletResponse.SC_NOT_FOUND, "Nuclues jail service not available");
        return;
    }

    NucleusJailService srv = optSrv.get();

    Optional<CachedNamedLocation> optRes = WebAPIAPI.runOnMain(() -> {
        Optional<NamedLocation> optJail = srv.getJail(name);
        if (!optJail.isPresent()) {
            data.sendError(HttpServletResponse.SC_NOT_FOUND, "Jail not found");
            return null;
        }

        return new CachedNamedLocation(optJail.get());
    });

    data.addData("ok", optRes.isPresent(), false);
    data.addData("jail", optRes.orElse(null), true);
}
 
開發者ID:Valandur,項目名稱:Web-API,代碼行數:23,代碼來源:NucleusServlet.java

示例3: getInfo

@Endpoint(method = HttpMethod.GET, path = "/", perm = "get")
public void getInfo(ServletData data) {
    Optional<Boolean> optRes = WebAPI.runOnMain(() -> {
        Server server = Sponge.getServer();
        Platform platform = Sponge.getPlatform();

        data.addData("motd", server.getMotd().toPlain(), false);
        data.addData("players", server.getOnlinePlayers().size(), false);
        data.addData("maxPlayers", server.getMaxPlayers(), false);
        data.addData("address", server.getBoundAddress().map(Object::toString).orElse(null), false);
        data.addData("onlineMode", server.getOnlineMode(), false);
        data.addData("resourcePack", server.getDefaultResourcePack().orElse(null), false);
        data.addData("hasWhitelist", server.hasWhitelist(), false);

        data.addData("uptimeTicks", server.getRunningTimeTicks(), false);
        data.addData("tps", server.getTicksPerSecond(), false);
        data.addData("minecraftVersion", platform.getMinecraftVersion().getName(), false);

        data.addData("game", platform.getContainer(Platform.Component.GAME), true);
        data.addData("api", platform.getContainer(Platform.Component.API), true);
        data.addData("implementation", platform.getContainer(Platform.Component.IMPLEMENTATION), true);
        return true;
    });

    data.addData("ok", optRes.orElse(false), false);
}
 
開發者ID:Valandur,項目名稱:Web-API,代碼行數:26,代碼來源:InfoServlet.java

示例4: getTileEntity

@Endpoint(method = HttpMethod.GET, path = "/:world/:x/:y/:z", perm = "one")
public void getTileEntity(ServletData data, CachedWorld world, int x, int y, int z) {
    Optional<ICachedTileEntity> te = cacheService.getTileEntity(world, x, y, z);

    if (!te.isPresent()) {
        data.sendError(HttpServletResponse.SC_NOT_FOUND, "Tile entity in world '" + world.getName() + "' at [" + x + "," + y + "," + z + "] could not be found");
        return;
    }

    Optional<String> strFields = data.getQueryParam("fields");
    Optional<String> strMethods = data.getQueryParam("methods");
    if (strFields.isPresent() || strMethods.isPresent()) {
        String[] fields = strFields.map(s -> s.split(",")).orElse(new String[]{});
        String[] methods = strMethods.map(s -> s.split(",")).orElse(new String[]{});
        Tuple extra = cacheService.getExtraData(te.get(), data.responseIsXml(), fields, methods);
        data.addData("fields", extra.getFirst(), true);
        data.addData("methods", extra.getSecond(), true);
    }

    data.addData("ok", true, false);
    data.addData("tileEntity", te.get(), true);
}
 
開發者ID:Valandur,項目名稱:Web-API,代碼行數:22,代碼來源:TileEntityServlet.java

示例5: getCrate

@Endpoint(method = HttpMethod.GET, path = "crate/:id", perm = "crate.one")
public void getCrate(IServletData data, String id) {
    HuskyCrates plugin = getHuskyPlugin(data);
    if (plugin == null) return;

    Optional<CachedVirtualCrate> optRes = WebAPIAPI.runOnMain(() -> {
        VirtualCrate crate = plugin.crateUtilities.getVirtualCrate(id);
        if (crate == null) {
            data.sendError(HttpServletResponse.SC_NOT_FOUND, "Crate not found");
            return null;
        }

        return new CachedVirtualCrate(crate);
    });

    data.addData("ok", optRes.isPresent(), false);
    data.addData("crate", optRes.orElse(null), true);
}
 
開發者ID:Valandur,項目名稱:Web-API,代碼行數:18,代碼來源:HuskyCratesServlet.java

示例6: getTickets

@Endpoint(method = HttpMethod.GET, path = "/ticket", perm = "list")
public void getTickets(IServletData data) {
    Main plugin = getMMCTicketsPlugin(data);
    if (plugin == null) return;

    Optional<List<CachedTicketData>> optTickets = WebAPIAPI.runOnMain(() -> {
        List<CachedTicketData> tickets = new ArrayList<>();
        for (TicketData ticket : plugin.getTickets()) {
            tickets.add(new CachedTicketData(ticket));
        }
        return tickets;
    });

    data.addData("ok", optTickets.isPresent(), false);
    data.addData("tickets", optTickets.orElse(null), data.getQueryParam("details").isPresent());
}
 
開發者ID:Valandur,項目名稱:Web-API,代碼行數:16,代碼來源:MMCTicketsServlet.java

示例7: getRegistry

@Endpoint(method = HttpMethod.GET, path = "/:class", perm = "one")
public void getRegistry(ServletData data, String className) {
    try {
        Class rawType = Class.forName(className);
        if (!CatalogType.class.isAssignableFrom(rawType)) {
            data.sendError(HttpServletResponse.SC_BAD_REQUEST, "Class must be a CatalogType");
            return;
        }
        Class<? extends CatalogType> type = rawType;

        if (registryCache.containsKey(type)) {
            data.addData("ok", true, false);
            data.addData("types", registryCache.get(type), false);
            return;
        }

        Optional<Collection<? extends CatalogType>> optTypes = WebAPI.runOnMain(() -> Sponge.getRegistry().getAllOf(type));
        optTypes.map(types -> registryCache.put(type, types));

        data.addData("ok", optTypes.isPresent(), false);
        data.addData("types", optTypes.orElse(null), false);
    } catch (ClassNotFoundException e) {
        data.sendError(HttpServletResponse.SC_NOT_FOUND, "Class " + className + " could not be found");
    }
}
 
開發者ID:Valandur,項目名稱:Web-API,代碼行數:25,代碼來源:RegistryServlet.java

示例8: getMessages

@Endpoint(method = HttpMethod.GET, path = "/", perm = "list")
public void getMessages(IServletData data) {
    List<IMessage> msgs = messageService.getMessages();

    data.addData("ok", true, false);
    data.addData("messages", msgs, data.getQueryParam("details").isPresent());
}
 
開發者ID:Valandur,項目名稱:Web-API,代碼行數:7,代碼來源:MessageServlet.java

示例9: getPlugin

@Endpoint(method = HttpMethod.GET, path = "/:plugin", perm = "one")
public void getPlugin(ServletData data, String pluginName) {
    Optional<ICachedPluginContainer> optPlugin = cacheService.getPlugin(pluginName);
    if (!optPlugin.isPresent()) {
        data.sendError(HttpServletResponse.SC_NOT_FOUND, "Plugin with id '" + pluginName + "' could not be found");
        return;
    }

    data.addData("ok", true, false);
    data.addData("plugin", optPlugin.get(), true);
}
 
開發者ID:Valandur,項目名稱:Web-API,代碼行數:11,代碼來源:PluginServlet.java

示例10: getWebBook

@Endpoint(method = HttpMethod.GET, path = "/book/:id", perm = "book.one")
public void getWebBook(IServletData data, String id) {
    WebBook book = books.get(id);
    if (book == null) {
        data.sendError(HttpServletResponse.SC_NOT_FOUND, "Book not found");
        return;
    }

    data.addData("ok", true, false);
    data.addData("book", book, true);
}
 
開發者ID:Valandur,項目名稱:Web-API,代碼行數:11,代碼來源:WebBookServlet.java

示例11: getStats

@Endpoint(method = HttpMethod.GET, path = "/stats", perm = "stats")
public void getStats(ServletData data) {
    data.addData("ok", true, true);
    data.addData("tps", serverService.getAverageTps(), false);
    data.addData("players", serverService.getOnlinePlayers(), false);
    data.addData("cpu", serverService.getCpuLoad(), false);
    data.addData("memory", serverService.getMemoryLoad(), false);
    data.addData("disk", serverService.getDiskUsage(), false);
}
 
開發者ID:Valandur,項目名稱:Web-API,代碼行數:9,代碼來源:InfoServlet.java

示例12: getServlets

@Endpoint(method = HttpMethod.GET, path = "/", perm = "list")
public void getServlets(ServletData data) {
    Map<String, Class<? extends BaseServlet>> servlets = servletService.getLoadedServlets();

    data.addData("ok", true, false);
    data.addData("servlets", servlets, false);
}
 
開發者ID:Valandur,項目名稱:Web-API,代碼行數:7,代碼來源:ServletServlet.java

示例13: getEntity

@Endpoint(method = HttpMethod.GET, path = "/:entity", perm = "one")
public void getEntity(ServletData data, CachedEntity entity) {
    Optional<String> strFields = data.getQueryParam("fields");
    Optional<String> strMethods = data.getQueryParam("methods");
    if (strFields.isPresent() || strMethods.isPresent()) {
        String[] fields = strFields.map(s -> s.split(",")).orElse(new String[]{});
        String[] methods = strMethods.map(s -> s.split(",")).orElse(new String[]{});
        Tuple extra = cacheService.getExtraData(entity, data.responseIsXml(), fields, methods);
        data.addData("fields", extra.getFirst(), true);
        data.addData("methods", extra.getSecond(), true);
    }

    data.addData("ok", true, false);
    data.addData("entity", entity, true);
}
 
開發者ID:Valandur,項目名稱:Web-API,代碼行數:15,代碼來源:EntityServlet.java

示例14: getPlugins

@Endpoint(method = HttpMethod.GET, path = "/", perm = "list")
public void getPlugins(ServletData data) {
    data.addData("ok", true, false);
    data.addData("plugins", cacheService.getPlugins(), data.getQueryParam("details").isPresent());
}
 
開發者ID:Valandur,項目名稱:Web-API,代碼行數:5,代碼來源:PluginServlet.java

示例15: listWebBooks

@Endpoint(method = HttpMethod.GET, path = "/book", perm = "book.list")
public void listWebBooks(IServletData data) {
    data.addData("ok", true, false);
    data.addData("books", books.values(), data.getQueryParam("details").isPresent());
}
 
開發者ID:Valandur,項目名稱:Web-API,代碼行數:5,代碼來源:WebBookServlet.java


注:本文中的org.eclipse.jetty.http.HttpMethod.GET屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。