PUT requests
This commit is contained in:
parent
b82effe163
commit
7a1ad105cd
@ -1,5 +1,5 @@
|
|||||||
mongoUri: mongodb://Admin:admin@15.160.229.161:27017/HQAPI?authMechanism=SCRAM-SHA-1&authSource=admin
|
mongoUri: mongodb://localhost:27017/HQAPI
|
||||||
redisUri: redis://15.160.229.161:6379
|
redisUri: redis://localhost:6379
|
||||||
|
|
||||||
network:
|
network:
|
||||||
name: MineHQ Network
|
name: MineHQ Network
|
||||||
|
@ -52,10 +52,7 @@ import net.frozenorb.apiv3.web.route.notificationTemplates.GETNotificationTempla
|
|||||||
import net.frozenorb.apiv3.web.route.notificationTemplates.GETNotificationTemplatesId;
|
import net.frozenorb.apiv3.web.route.notificationTemplates.GETNotificationTemplatesId;
|
||||||
import net.frozenorb.apiv3.web.route.notificationTemplates.POSTNotificationTemplates;
|
import net.frozenorb.apiv3.web.route.notificationTemplates.POSTNotificationTemplates;
|
||||||
import net.frozenorb.apiv3.web.route.phoneIntel.GETPhoneInteld;
|
import net.frozenorb.apiv3.web.route.phoneIntel.GETPhoneInteld;
|
||||||
import net.frozenorb.apiv3.web.route.prefix.DELETEPrefixesId;
|
import net.frozenorb.apiv3.web.route.prefix.*;
|
||||||
import net.frozenorb.apiv3.web.route.prefix.GETPrefixes;
|
|
||||||
import net.frozenorb.apiv3.web.route.prefix.GETPrefixesId;
|
|
||||||
import net.frozenorb.apiv3.web.route.prefix.POSTPrefixes;
|
|
||||||
import net.frozenorb.apiv3.web.route.prefixGrants.DELETEPrefixGrantsId;
|
import net.frozenorb.apiv3.web.route.prefixGrants.DELETEPrefixGrantsId;
|
||||||
import net.frozenorb.apiv3.web.route.prefixGrants.GETPrefixGrants;
|
import net.frozenorb.apiv3.web.route.prefixGrants.GETPrefixGrants;
|
||||||
import net.frozenorb.apiv3.web.route.prefixGrants.GETPrefixGrantsId;
|
import net.frozenorb.apiv3.web.route.prefixGrants.GETPrefixGrantsId;
|
||||||
@ -65,21 +62,9 @@ import net.frozenorb.apiv3.web.route.punishments.DELETEUsersIdActivePunishment;
|
|||||||
import net.frozenorb.apiv3.web.route.punishments.GETPunishments;
|
import net.frozenorb.apiv3.web.route.punishments.GETPunishments;
|
||||||
import net.frozenorb.apiv3.web.route.punishments.GETPunishmentsId;
|
import net.frozenorb.apiv3.web.route.punishments.GETPunishmentsId;
|
||||||
import net.frozenorb.apiv3.web.route.punishments.POSTPunishments;
|
import net.frozenorb.apiv3.web.route.punishments.POSTPunishments;
|
||||||
import net.frozenorb.apiv3.web.route.ranks.DELETERanksId;
|
import net.frozenorb.apiv3.web.route.ranks.*;
|
||||||
import net.frozenorb.apiv3.web.route.ranks.GETRanks;
|
import net.frozenorb.apiv3.web.route.serverGroups.*;
|
||||||
import net.frozenorb.apiv3.web.route.ranks.GETRanksId;
|
import net.frozenorb.apiv3.web.route.servers.*;
|
||||||
import net.frozenorb.apiv3.web.route.ranks.POSTRanks;
|
|
||||||
import net.frozenorb.apiv3.web.route.serverGroups.DELETEServerGroupsId;
|
|
||||||
import net.frozenorb.apiv3.web.route.serverGroups.GETServerGroups;
|
|
||||||
import net.frozenorb.apiv3.web.route.serverGroups.GETServerGroupsId;
|
|
||||||
import net.frozenorb.apiv3.web.route.serverGroups.GETServerGroupsPlayerCount;
|
|
||||||
import net.frozenorb.apiv3.web.route.serverGroups.POSTServerGroups;
|
|
||||||
import net.frozenorb.apiv3.web.route.servers.DELETEServersId;
|
|
||||||
import net.frozenorb.apiv3.web.route.servers.GETServers;
|
|
||||||
import net.frozenorb.apiv3.web.route.servers.GETServersId;
|
|
||||||
import net.frozenorb.apiv3.web.route.servers.GETServersPlayerCountId;
|
|
||||||
import net.frozenorb.apiv3.web.route.servers.POSTServers;
|
|
||||||
import net.frozenorb.apiv3.web.route.servers.POSTServersHeartbeat;
|
|
||||||
import net.frozenorb.apiv3.web.route.users.*;
|
import net.frozenorb.apiv3.web.route.users.*;
|
||||||
import net.frozenorb.apiv3.util.SpringUtils;
|
import net.frozenorb.apiv3.util.SpringUtils;
|
||||||
|
|
||||||
@ -204,14 +189,14 @@ public final class APIv3 {
|
|||||||
httpGet(router, "/ranks/:rankId", GETRanksId.class);
|
httpGet(router, "/ranks/:rankId", GETRanksId.class);
|
||||||
httpGet(router, "/ranks", GETRanks.class);
|
httpGet(router, "/ranks", GETRanks.class);
|
||||||
httpPost(router, "/ranks", POSTRanks.class);
|
httpPost(router, "/ranks", POSTRanks.class);
|
||||||
//httpPut(router, "/ranks/:rankId", PUTRanksId.class);
|
httpPut(router, "/ranks/:rankId", PUTRanksId.class);
|
||||||
httpDelete(router, "/ranks/:rankId", DELETERanksId.class);
|
httpDelete(router, "/ranks/:rankId", DELETERanksId.class);
|
||||||
|
|
||||||
httpGet(router, "/serverGroups/:serverGroupId", GETServerGroupsId.class);
|
httpGet(router, "/serverGroups/:serverGroupId", GETServerGroupsId.class);
|
||||||
httpGet(router, "/serverGroups/:serverGroupId/playerCount", GETServerGroupsPlayerCount.class);
|
httpGet(router, "/serverGroups/:serverGroupId/playerCount", GETServerGroupsPlayerCount.class);
|
||||||
httpGet(router, "/serverGroups", GETServerGroups.class);
|
httpGet(router, "/serverGroups", GETServerGroups.class);
|
||||||
httpPost(router, "/serverGroups", POSTServerGroups.class);
|
httpPost(router, "/serverGroups", POSTServerGroups.class);
|
||||||
//httpPut(router, "/serverGroups/:serverGroupId", PUTServerGroupsId.class);
|
httpPut(router, "/serverGroups/:serverGroupId", PUTServerGroupsId.class);
|
||||||
httpDelete(router, "/serverGroups/:serverGroupId", DELETEServerGroupsId.class);
|
httpDelete(router, "/serverGroups/:serverGroupId", DELETEServerGroupsId.class);
|
||||||
|
|
||||||
httpGet(router, "/servers/:serverId", GETServersId.class);
|
httpGet(router, "/servers/:serverId", GETServersId.class);
|
||||||
@ -219,13 +204,13 @@ public final class APIv3 {
|
|||||||
httpGet(router, "/servers", GETServers.class);
|
httpGet(router, "/servers", GETServers.class);
|
||||||
httpPost(router, "/servers/heartbeat", POSTServersHeartbeat.class);
|
httpPost(router, "/servers/heartbeat", POSTServersHeartbeat.class);
|
||||||
httpPost(router, "/servers", POSTServers.class);
|
httpPost(router, "/servers", POSTServers.class);
|
||||||
//httpPut(router, "/servers/:serverId", PUTServersId.class);
|
httpPut(router, "/servers/:serverId", PUTServersId.class);
|
||||||
httpDelete(router, "/servers/:serverId", DELETEServersId.class);
|
httpDelete(router, "/servers/:serverId", DELETEServersId.class);
|
||||||
|
|
||||||
httpGet(router, "/prefixes/:prefixId", GETPrefixesId.class);
|
httpGet(router, "/prefixes/:prefixId", GETPrefixesId.class);
|
||||||
httpGet(router, "/prefixes", GETPrefixes.class);
|
httpGet(router, "/prefixes", GETPrefixes.class);
|
||||||
httpPost(router, "/prefixes", POSTPrefixes.class);
|
httpPost(router, "/prefixes", POSTPrefixes.class);
|
||||||
//httpPut(router, "/prefixes/:prefixId", PUTPrefixesId.class);
|
httpPut(router, "/prefixes/:prefixId", PUTPrefixesId.class);
|
||||||
httpDelete(router, "/prefixes/:prefixId", DELETEPrefixesId.class);
|
httpDelete(router, "/prefixes/:prefixId", DELETEPrefixesId.class);
|
||||||
|
|
||||||
httpGet(router, "/prefixes/grants/:grantId", GETPrefixGrantsId.class);
|
httpGet(router, "/prefixes/grants/:grantId", GETPrefixGrantsId.class);
|
||||||
@ -290,6 +275,10 @@ public final class APIv3 {
|
|||||||
router.get(route).blockingHandler((Handler<RoutingContext>) SpringUtils.getBean(handler), false);
|
router.get(route).blockingHandler((Handler<RoutingContext>) SpringUtils.getBean(handler), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void httpPut(Router router, String route, Class<?> handler) {
|
||||||
|
router.put(route).blockingHandler((Handler<RoutingContext>) SpringUtils.getBean(handler), false);
|
||||||
|
}
|
||||||
|
|
||||||
private void httpPost(Router router, String route, Class<?> handler) {
|
private void httpPost(Router router, String route, Class<?> handler) {
|
||||||
router.post(route).blockingHandler((Handler<RoutingContext>) SpringUtils.getBean(handler), false);
|
router.post(route).blockingHandler((Handler<RoutingContext>) SpringUtils.getBean(handler), false);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,10 @@ public class ErrorUtils {
|
|||||||
respond(ctx, 404, "Not found: " + itemType + " with id " + id + " cannot be found.", null, null);
|
respond(ctx, 404, "Not found: " + itemType + " with id " + id + " cannot be found.", null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void alreadyFound(RoutingContext ctx, String itemType, String id) {
|
||||||
|
respond(ctx, 404, "Already exists: " + itemType + " with id " + id + " already exists.", null, null);
|
||||||
|
}
|
||||||
|
|
||||||
public static void respondInvalidInput(RoutingContext ctx, String message) {
|
public static void respondInvalidInput(RoutingContext ctx, String message) {
|
||||||
respond(ctx, 400, "Invalid input: " + message, null, null);
|
respond(ctx, 400, "Invalid input: " + message, null, null);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,33 @@
|
|||||||
package net.frozenorb.apiv3.web.route.prefix;
|
package net.frozenorb.apiv3.web.route.prefix;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import io.vertx.core.Handler;
|
||||||
|
import io.vertx.core.json.JsonObject;
|
||||||
|
import io.vertx.ext.web.RoutingContext;
|
||||||
|
import net.frozenorb.apiv3.domain.Prefix;
|
||||||
|
import net.frozenorb.apiv3.domain.Rank;
|
||||||
|
import net.frozenorb.apiv3.util.ErrorUtils;
|
||||||
|
import net.frozenorb.apiv3.util.SpringUtils;
|
||||||
|
import net.frozenorb.apiv3.util.SyncUtils;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class PUTPrefixesId {
|
public class PUTPrefixesId implements Handler<RoutingContext> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(RoutingContext ctx) {
|
||||||
|
JsonObject body = ctx.getBodyAsJson();
|
||||||
|
Prefix prefix = Prefix.findById(body.getString("id"));
|
||||||
|
|
||||||
|
if (prefix != null) {
|
||||||
|
ErrorUtils.alreadyFound(ctx, "Prefix", ctx.request().getParam("prefixId"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
prefix = SpringUtils.getBean(Gson.class)
|
||||||
|
.fromJson(ctx.getBodyAsJson().toString(), Prefix.class);
|
||||||
|
|
||||||
|
SyncUtils.<Void>runBlocking(prefix::insert);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,33 @@
|
|||||||
package net.frozenorb.apiv3.web.route.ranks;
|
package net.frozenorb.apiv3.web.route.ranks;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import io.vertx.core.Handler;
|
||||||
|
import io.vertx.core.http.HttpServerRequest;
|
||||||
|
import io.vertx.core.json.JsonObject;
|
||||||
|
import io.vertx.ext.web.RoutingContext;
|
||||||
|
import net.frozenorb.apiv3.domain.Rank;
|
||||||
|
import net.frozenorb.apiv3.util.ErrorUtils;
|
||||||
|
import net.frozenorb.apiv3.util.SpringUtils;
|
||||||
|
import net.frozenorb.apiv3.util.SyncUtils;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class PUTRanksId {
|
public class PUTRanksId implements Handler<RoutingContext> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(RoutingContext ctx) {
|
||||||
|
JsonObject body = ctx.getBodyAsJson();
|
||||||
|
Rank rank = Rank.findById(body.getString("id"));
|
||||||
|
|
||||||
|
if (rank != null) {
|
||||||
|
ErrorUtils.alreadyFound(ctx, "Rank", ctx.request().getParam("rankId"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
rank = SpringUtils.getBean(Gson.class)
|
||||||
|
.fromJson(ctx.getBodyAsJson().toString(), Rank.class);
|
||||||
|
|
||||||
|
SyncUtils.<Void>runBlocking(rank::insert);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,32 @@
|
|||||||
package net.frozenorb.apiv3.web.route.serverGroups;
|
package net.frozenorb.apiv3.web.route.serverGroups;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import io.vertx.core.Handler;
|
||||||
|
import io.vertx.core.json.JsonObject;
|
||||||
|
import io.vertx.ext.web.RoutingContext;
|
||||||
|
import net.frozenorb.apiv3.domain.ServerGroup;
|
||||||
|
import net.frozenorb.apiv3.util.ErrorUtils;
|
||||||
|
import net.frozenorb.apiv3.util.SpringUtils;
|
||||||
|
import net.frozenorb.apiv3.util.SyncUtils;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class PUTServerGroupsId {
|
public class PUTServerGroupsId implements Handler<RoutingContext> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(RoutingContext ctx) {
|
||||||
|
JsonObject body = ctx.getBodyAsJson();
|
||||||
|
ServerGroup serverGroup = ServerGroup.findById(body.getString("id"));
|
||||||
|
|
||||||
|
if (serverGroup != null) {
|
||||||
|
ErrorUtils.alreadyFound(ctx, "ServerGroup", ctx.request().getParam("serverGroupId"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
serverGroup = SpringUtils.getBean(Gson.class)
|
||||||
|
.fromJson(ctx.getBodyAsJson().toString(), ServerGroup.class);
|
||||||
|
|
||||||
|
SyncUtils.<Void>runBlocking(serverGroup::insert);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,7 +1,33 @@
|
|||||||
package net.frozenorb.apiv3.web.route.servers;
|
package net.frozenorb.apiv3.web.route.servers;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import io.vertx.core.Handler;
|
||||||
|
import io.vertx.core.json.JsonObject;
|
||||||
|
import io.vertx.ext.web.RoutingContext;
|
||||||
|
import net.frozenorb.apiv3.domain.Prefix;
|
||||||
|
import net.frozenorb.apiv3.domain.Server;
|
||||||
|
import net.frozenorb.apiv3.util.ErrorUtils;
|
||||||
|
import net.frozenorb.apiv3.util.SpringUtils;
|
||||||
|
import net.frozenorb.apiv3.util.SyncUtils;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class PUTServersId {
|
public class PUTServersId implements Handler<RoutingContext> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(RoutingContext ctx) {
|
||||||
|
JsonObject body = ctx.getBodyAsJson();
|
||||||
|
Server server = Server.findById(body.getString("id"));
|
||||||
|
|
||||||
|
if (server != null) {
|
||||||
|
ErrorUtils.alreadyFound(ctx, "Server", ctx.request().getParam("serverId"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
server = SpringUtils.getBean(Gson.class)
|
||||||
|
.fromJson(ctx.getBodyAsJson().toString(), Server.class);
|
||||||
|
|
||||||
|
SyncUtils.<Void>runBlocking(server::insert);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user