Rename routers to fit their respective routes better
This commit is contained in:
parent
516f831277
commit
3f5c9ed3a0
@ -35,13 +35,13 @@ public final class APIv3 extends AbstractVerticle {
|
|||||||
});
|
});
|
||||||
|
|
||||||
rootRouter.mountSubRouter("/auditLog", AuditLogRouter.create(vertx));
|
rootRouter.mountSubRouter("/auditLog", AuditLogRouter.create(vertx));
|
||||||
rootRouter.mountSubRouter("/grants", GrantRouter.create(vertx));
|
rootRouter.mountSubRouter("/grants", GrantsRouter.create(vertx));
|
||||||
rootRouter.mountSubRouter("/ipLog", IPLogRouter.create(vertx));
|
rootRouter.mountSubRouter("/ipLog", IPLogRouter.create(vertx));
|
||||||
rootRouter.mountSubRouter("/notifications", NotificationRouter.create(vertx));
|
rootRouter.mountSubRouter("/notifications", NotificationsRouter.create(vertx));
|
||||||
rootRouter.mountSubRouter("/punishments", PunishmentRouter.create(vertx));
|
rootRouter.mountSubRouter("/punishments", PunishmentsRouter.create(vertx));
|
||||||
rootRouter.mountSubRouter("/serverGroups", ServerGroupRouter.create(vertx));
|
rootRouter.mountSubRouter("/serverGroups", ServerGroupsRouter.create(vertx));
|
||||||
rootRouter.mountSubRouter("/servers", ServerGroupRouter.create(vertx));
|
rootRouter.mountSubRouter("/servers", ServersRouter.create(vertx));
|
||||||
rootRouter.mountSubRouter("/users", UserRouter.create(vertx));
|
rootRouter.mountSubRouter("/users", UsersRouter.create(vertx));
|
||||||
|
|
||||||
vertx.createHttpServer().requestHandler(rootRouter::accept).listen(8080);
|
vertx.createHttpServer().requestHandler(rootRouter::accept).listen(8080);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import io.vertx.ext.web.Router;
|
|||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class GrantRouter {
|
public class GrantsRouter {
|
||||||
|
|
||||||
public static Router create(Vertx vertx) {
|
public static Router create(Vertx vertx) {
|
||||||
Router router = Router.router(vertx);
|
Router router = Router.router(vertx);
|
@ -5,7 +5,7 @@ import io.vertx.ext.web.Router;
|
|||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class PunishmentRouter {
|
public class NotificationsRouter {
|
||||||
|
|
||||||
public static Router create(Vertx vertx) {
|
public static Router create(Vertx vertx) {
|
||||||
Router router = Router.router(vertx);
|
Router router = Router.router(vertx);
|
@ -5,7 +5,7 @@ import io.vertx.ext.web.Router;
|
|||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class UserRouter {
|
public class PunishmentsRouter {
|
||||||
|
|
||||||
public static Router create(Vertx vertx) {
|
public static Router create(Vertx vertx) {
|
||||||
Router router = Router.router(vertx);
|
Router router = Router.router(vertx);
|
@ -1,18 +0,0 @@
|
|||||||
package net.frozenorb.apiv3.routes;
|
|
||||||
|
|
||||||
import io.vertx.core.Vertx;
|
|
||||||
import io.vertx.ext.web.Router;
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
@UtilityClass
|
|
||||||
public class ServerGroupRouter {
|
|
||||||
|
|
||||||
public static Router create(Vertx vertx) {
|
|
||||||
Router router = Router.router(vertx);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return router;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -5,7 +5,7 @@ import io.vertx.ext.web.Router;
|
|||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class NotificationRouter {
|
public class ServerGroupsRouter {
|
||||||
|
|
||||||
public static Router create(Vertx vertx) {
|
public static Router create(Vertx vertx) {
|
||||||
Router router = Router.router(vertx);
|
Router router = Router.router(vertx);
|
@ -5,7 +5,7 @@ import io.vertx.ext.web.Router;
|
|||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class ServerRouter {
|
public class ServersRouter {
|
||||||
|
|
||||||
public static Router create(Vertx vertx) {
|
public static Router create(Vertx vertx) {
|
||||||
Router router = Router.router(vertx);
|
Router router = Router.router(vertx);
|
35
src/main/java/net/frozenorb/apiv3/routes/UsersRouter.java
Normal file
35
src/main/java/net/frozenorb/apiv3/routes/UsersRouter.java
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package net.frozenorb.apiv3.routes;
|
||||||
|
|
||||||
|
import io.vertx.core.Vertx;
|
||||||
|
import io.vertx.ext.web.Router;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
import net.frozenorb.apiv3.accessor.Users;
|
||||||
|
import net.frozenorb.apiv3.util.ErrorUtils;
|
||||||
|
import net.frozenorb.apiv3.util.JsonUtils;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@UtilityClass
|
||||||
|
public class UsersRouter {
|
||||||
|
|
||||||
|
public static Router create(Vertx vertx) {
|
||||||
|
Router router = Router.router(vertx);
|
||||||
|
|
||||||
|
router.get("/info/:user").handler(ctx -> {
|
||||||
|
UUID target = UUID.fromString(ctx.request().getParam("user"));
|
||||||
|
|
||||||
|
Users.findById(target, (user, error) -> {
|
||||||
|
if (error != null) {
|
||||||
|
ctx.response().end(ErrorUtils.toResponseString(error));
|
||||||
|
} else if (user != null) {
|
||||||
|
ctx.response().end(JsonUtils.toLiteJsonString(user));
|
||||||
|
} else {
|
||||||
|
ctx.response().end(ErrorUtils.toResponseString("User '" + target + "' not found."));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return router;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user