本文整理汇总了Java中io.vertx.core.http.HttpServerRequest.getParam方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServerRequest.getParam方法的具体用法?Java HttpServerRequest.getParam怎么用?Java HttpServerRequest.getParam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.http.HttpServerRequest
的用法示例。
在下文中一共展示了HttpServerRequest.getParam方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateAlipayPaySetting
import io.vertx.core.http.HttpServerRequest; //导入方法依赖的package包/类
private void updateAlipayPaySetting(RoutingContext rc) {
if (forbidAccess(rc, "uid", true)) {
return;
}
HttpServerRequest req = rc.request();
HttpServerResponse resp = rc.response().putHeader("content-type", "application/json; charset=utf-8");
//解析参数
Long uid = Long.parseLong(req.getParam("uid"));
Integer paySwitch = Integer.parseInt(req.getParam("paySwitch"));
String appId = req.getParam("appId");
String appPrivKey = req.getParam("appPrivKey");
String zfbPubKey = req.getParam("zfbPubKey");
//参数检查
if (paySwitch == 1 && !CommonUtils.notEmptyString(appId, appPrivKey, zfbPubKey)) {
resp.end(new JsonObject().put("status", "invalid").toString());
return;
}
//保存支付参数
JsonObject acc = new JsonObject().put(ID, uid).put(ZFBAPPID, appId).put(ZFBPRIVKEY, appPrivKey).put(ZFBPUBKEY, zfbPubKey).put(ZFBPAYON, paySwitch);
updatePaySetting(resp, acc, COMMAND_UPDATE_ALIPAY);
}
示例2: updateOfficialAccount
import io.vertx.core.http.HttpServerRequest; //导入方法依赖的package包/类
/**
* 更新公众号配置
* 请求方法:PUT
* 请求参数:id,name邮箱,appid,appsecret,verify
* 响应:success或fail
*/
private void updateOfficialAccount(RoutingContext rc) {
if (forbidAccess(rc, "id", true)) {
return;
}
HttpServerRequest req = rc.request();
Long id = Long.valueOf(req.getParam("id"));
String name = req.getParam("name");
String appid = req.getParam("appid");
String appsecret = req.getParam("appsecret");
String verify = req.getParam("verify");
JsonObject updateAcc = new JsonObject().put(ID, id).put(NAME, name).put(WXAPPID, appid).put(WXAPPSECRET, appsecret).put(VERIFY, verify);
log.debug("更新公众号配置:{}", updateAcc);
vertx.eventBus().<Integer>send(ADDR_ACCOUNT_DB.get(), makeMessage(COMMAND_UPDATE_NORMAL, updateAcc), ar -> {
HttpServerResponse response = rc.response();
if(ar.succeeded()){
Integer rows = ar.result().body();
response.putHeader("content-type", "application/json; charset=utf-8").end(rows > 0 ? "success" : "fail");
} else {
log.error("EventBus消息响应错误", ar.cause());
response.setStatusCode(500).end("EventBus error!");
}
});
}
示例3: handle
import io.vertx.core.http.HttpServerRequest; //导入方法依赖的package包/类
public void handle(RoutingContext ctx) {
HttpServerResponse response = ctx.response();
HttpServerRequest request = ctx.request();
String apiKey = request.getParam("api_key");
String host = request.getParam("host_name");
if (Guardian.checkParameters(apiKey, host) && userManager.isLogined(ctx)) {
try {
String uid = userManager.getUid(userManager.getIdFromSession(ctx));
if(requestManager.addHost(uid, apiKey, host)){
response.setStatusCode(200);
}else{
response.setStatusCode(304);
}
} catch (SQLException e) {
e.printStackTrace();
response.setStatusCode(500);
}
} else {
response.setStatusCode(400);
}
response.end();
response.close();
}
示例4: getDevNode
import io.vertx.core.http.HttpServerRequest; //导入方法依赖的package包/类
public Node getDevNode(App app,HttpServerRequest clientRequest){
String hostport = clientRequest.getParam(app.name);
String remoteip = clientRequest.remoteAddress().host();
if(S.isNotBlank(hostport)){
if("clear".equals(hostport)){
devMode.remove(remoteip);
log.debug("clear node of remote ip:"+remoteip);
return null;
}else{
String[] ipp = hostport.split(":");
Node n = app.createDevNode(ipp[0], Integer.parseInt(ipp[1]),1);
devMode.put(remoteip, n);
log.debug("remote ip visit setting:"+remoteip+" ["+app.name+"->"+hostport+"]");
return n;
}
}else{
return devMode.get(remoteip);
}
}
示例5: oauthSuccessProcess
import io.vertx.core.http.HttpServerRequest; //导入方法依赖的package包/类
/**
* 解析授权前访问的地址,解析所需的json并编码,最后重定向
*
* @param req HTTP请求对象
* @param resp HTTP响应对象
* @param res ALipay接口返回的响应
* @param callback 解析地址后的处理方法
* @author Leibniz.Hu
*/
private void oauthSuccessProcess(HttpServerRequest req, HttpServerResponse resp, AlipayResponse res, Handler<String> callback) {
if (res != null) {
String visitUrl = req.getParam("visitUrl");//getRedirectAddress(request, REMOVE_PARAMS);
if (visitUrl.length() > 0) {
visitUrl = TuringBase64Util.decode(visitUrl).replaceAll("[\\s*\t\n\r]", "");
callback.handle(visitUrl);
resp.setStatusCode(302).putHeader("Location", visitUrl + (visitUrl.contains("?") ? "&rs=" : "?rs=") + TuringBase64Util.encode(getClearJson(res).toString())).end();
} else {
log.error("没有找到授权后回调地址" + req.absoluteURI());
resp.end("未设置授权后回调地址");
}
}
}
示例6: getParam
import io.vertx.core.http.HttpServerRequest; //导入方法依赖的package包/类
private static String getParam(String mountPoint, HttpServerRequest request, int index) {
String param = request.getParam("param" + index);
if (param == null) { // failed to get directly ... try from request path
String path = removeMountPoint(mountPoint, request.path());
String[] items = path.split("/");
if (index < items.length) { // simplistic way to find param value from path by index
return items[index];
}
}
return null;
}
示例7: register
import io.vertx.core.http.HttpServerRequest; //导入方法依赖的package包/类
private void register(RoutingContext rc) {
HttpServerRequest req = rc.request();
HttpServerResponse resp = rc.response();
String email = req.getParam("email");
String name = req.getParam("name");
String password = req.getParam("password");
String rePassword = req.getParam("repassword");
//参数判定
if (email == null || email.trim().length() == 0) {
log.error("输入的邮箱为空");
resp.setStatusCode(500).end("EMPTY_EMAIL");
return;
}
if (name == null || name.trim().length() == 0) {
log.error("输入的用户名为空");
resp.setStatusCode(500).end("EMPTY_NAME");
return;
}
if (password == null || password.trim().length() == 0) {
log.error("输入的密码为空");
resp.setStatusCode(500).end("EMPTY_PSWD");
return;
}
if (rePassword == null || rePassword.trim().length() == 0) {
log.error("输入的重复密码为空");
resp.setStatusCode(500).end("EMPTY_REPEAT_PSWD");
return;
}
if (!password.trim().equals(rePassword.trim())) {
log.error("输入的新密码({})与重复密码不一致({})", password, rePassword);
resp.setStatusCode(500).end("PSWD_NOT_EQUAL");
return;
}
//注册处理
log.debug("有用户注册请求,email={}登录密码MD5={}。", email, password);
vertx.eventBus().<Integer>send(ADDR_ACCOUNT_DB.get(), makeMessage(COMMAND_REGISTER, email, password, name),
ar -> {
if (ar.succeeded()) {
JsonObject result = new JsonObject();
Integer id = ar.result().body();
if(id == -1){
resp.setStatusCode(500).end("DUPLICATE_EMAIL");
return;
}
//jwt保存
String token = provider.generateToken(new JsonObject().put("id", id).put("role", 1), JWT_OPTIONS);
log.info("用户({},{})注册成功,ID={},角色=普通用户,token={}", name, email, id, token);
result.put("result", "success").put("token", token).put("name", name).put("role", 1)
.put("id", id).put("email", email);
resp.end(result.toString());
} else {
log.error("EventBus消息响应错误", ar.cause());
resp.setStatusCode(500).end("EventBus error!");
}
});
}
示例8: updateWechatPaySetting
import io.vertx.core.http.HttpServerRequest; //导入方法依赖的package包/类
private void updateWechatPaySetting(RoutingContext rc) {
if (forbidAccess(rc, "uid", true)) {
return;
}
Set<FileUpload> uploads = rc.fileUploads();
HttpServerRequest req = rc.request();
HttpServerResponse resp = rc.response().putHeader("content-type", "application/json; charset=utf-8");
//解析参数
Long uid = Long.parseLong(req.getParam("uid"));
Integer paySwitch = Integer.parseInt(req.getParam("paySwitch"));
String mchId = req.getParam("mchId");
String payKey = req.getParam("payKey");
//参数检查
if (paySwitch == 1 && !CommonUtils.notEmptyString(mchId, payKey)) {
resp.end(new JsonObject().put("status", "invalid").toString());
return;
}
// 异步保存证书文件
if (uploads != null && !uploads.isEmpty()) {
for (FileUpload next : uploads) {
if (paySwitch == 1 && "cert".equals(next.name()) && next.size() > 0) {
String filePath = Constants.CERT_DIR + uid + "_wxPay.p12";
FileSystem fs = this.vertx.fileSystem();
fs.exists(filePath, ex -> {
if(ex.succeeded()){
Future<Void> delFuture = Future.future();
Future<Void> copyFuture = Future.future();
fs.delete(filePath, delFuture.completer());
fs.copy(next.uploadedFileName(), filePath, copyFuture.completer());
if(ex.result()){
delFuture.compose(res -> {}, copyFuture);
}
copyFuture.setHandler(res -> {
if (res.succeeded()) {
log.info("复制文件{}到{}成功!", next.uploadedFileName(), filePath);
} else {
log.error("复制文件" + next.uploadedFileName() + "到" + filePath + "失败!", res.cause());
}
});
} else {
log.error("判断文件" + filePath + "是否存在时抛出异常!", ex.cause());
}
});
break;
}
}
}
//保存支付参数
JsonObject acc = new JsonObject().put(ID, uid).put(MCHID, mchId).put(MCHKEY, payKey).put(WXPAYON, paySwitch);
updatePaySetting(resp, acc, COMMAND_UPDATE_WECHATPAY);
}
示例9: updateEmailPassword
import io.vertx.core.http.HttpServerRequest; //导入方法依赖的package包/类
/**
* 更新邮箱密码
* 请求方法:PUT
* 请求参数:id,oldPassword旧密码,newPassword新密码,rePasswordo重复密码
* 响应:success或fail
*/
private void updateEmailPassword(RoutingContext rc) {
if (forbidAccess(rc, "id", true)) {
return;
}
HttpServerRequest req = rc.request();
HttpServerResponse resp = rc.response().putHeader("content-type", "text/plain; charset=utf-8");
Long id = Long.valueOf(req.getParam("id"));
String oldPassword = req.getParam("oldPassword");
log.debug("即将发送EventBus消息查询(ID={},密码={})是否正确", id, oldPassword);
Future.<Message<JsonObject>>future(f ->
vertx.eventBus().send(ADDR_ACCOUNT_DB.get(), makeMessage(COMMAND_ID_LOGIN, id, oldPassword), f)
).compose(msg ->
Future.<Message<Integer>>future(f -> {
JsonObject acc = msg.body();
if (acc == null) {
log.warn("账户({})不存在或密码({})错误", id, oldPassword);
rc.response().end("errPswd");
return;
}
String email = req.getParam("email");
String newPassword = req.getParam("newPassword");
boolean needUpdatePassword = false;
if (newPassword != null && newPassword.trim().length() > 0) {
String rePassword = req.getParam("rePassword");
if (rePassword == null || rePassword.trim().length() == 0) {
log.error("输入的重复密码为空");
resp.setStatusCode(500).end("EMPTY_REPEAT_PSWD");
return;
}
if (!newPassword.trim().equals(rePassword.trim())) {
log.error("输入的新密码({})与重复密码不一致({})", newPassword, rePassword);
resp.setStatusCode(500).end("PSWD_NOT_EQUAL");
return;
}
needUpdatePassword = true;
}
JsonObject updateAcc = new JsonObject().put(ID, id).put(EMAIL, email);
if (needUpdatePassword) {
updateAcc.put(PASSWORD, newPassword);
}
vertx.eventBus().send(ADDR_ACCOUNT_DB.get(), makeMessage(COMMAND_UPDATE_NORMAL, updateAcc), f);
})
).setHandler(res -> {
if(res.succeeded()){
Integer rows = res.result().body();
log.info("更新密码/邮箱完毕,影响了{}条数据库记录", rows);
rc.response().end(rows > 0 ? "success" : "fail");
} else {
log.error("更新密码/邮箱时抛出异常", res.cause());
rc.response().setStatusCode(500).end();
}
});
}
示例10: handle
import io.vertx.core.http.HttpServerRequest; //导入方法依赖的package包/类
@Override
public void handle(RoutingContext ctx, Server server, DiscordBot bot, DSLContext database) {
HttpServerRequest request = ctx.request();
HttpServerResponse response = ctx.response();
String guildId = request.getParam("guildId");
int shardId = DiscordUtils.getShardIdFromGuildId(Long.parseLong(guildId), bot.getConfig().jim.shard_count);
JDA shard = bot.getShards().get(shardId).getShard();
Guild guild = shard.getGuildById(guildId);
SettingsRecord record = database.selectFrom(Tables.SETTINGS)
.where(Tables.SETTINGS.GUILDID.eq(guildId))
.fetchAny();
if (record == null || guild == null) {
response.setStatusCode(404);
response.end();
return;
}
Gson gson = new GsonBuilder().serializeNulls().create();
List<PartialChannel> channels = guild.getTextChannels()
.stream()
.map((channel) -> new PartialChannel(channel.getId(), channel.getName()))
.collect(Collectors.toList());
List<PartialRole> roles = guild.getRoles()
.stream()
.map((role) -> new PartialRole(role.getId(), role.getName()))
.collect(Collectors.toList());
Channel modLogChannel = shard.getTextChannelById(record.getModlogchannelid());
PartialChannel modLogChannelPartial = new PartialChannel(modLogChannel.getId(), modLogChannel.getName());
Channel welcomeMessageChannel = shard.getTextChannelById(record.getWelcomemessagechannelid());
PartialChannel welcomeMessageChannelPartial = new PartialChannel(welcomeMessageChannel.getId(), welcomeMessageChannel.getName());
Role holdingRoomRole = null;
PartialRole holdingRoomRolePartial = null;
if (record.getHoldingroomroleid() != null) {
holdingRoomRole = shard.getRoleById(record.getHoldingroomroleid());
holdingRoomRolePartial = new PartialRole(holdingRoomRole.getId(), holdingRoomRole.getName());
}
GuildSettings settings = new GuildSettings(
guildId,
record.getModlog(),
modLogChannelPartial,
record.getHoldingroom(),
holdingRoomRolePartial,
record.getHoldingroomminutes(),
record.getInvitelinkremover(),
record.getWelcomemessage(),
record.getMessage(),
welcomeMessageChannelPartial,
record.getPrefix(),
record.getSilentcommands(),
record.getNospaceprefix(),
record.getStatistics(),
channels,
roles
);
String responseJson = gson.toJson(settings);
response.putHeader("Content-Type", "application/json");
response.end(responseJson);
}
示例11: handle
import io.vertx.core.http.HttpServerRequest; //导入方法依赖的package包/类
@Override
public void handle(RoutingContext ctx, Server server, DiscordBot bot, DSLContext database) {
HttpServerRequest request = ctx.request();
HttpServerResponse response = ctx.response();
String userId = ServerUtils.authUser(request, response, config);
if (userId == null) {
return;
}
String guildId = request.getParam("guildId");
String channelId = request.getParam("channelId");
String fromParam = request.getParam("from");
String toParam = request.getParam("to");
long from;
long to;
try {
from = Long.parseLong(fromParam);
to = Long.parseLong(toParam);
if (from <= 0 || to <= 0 || from >= to) {
response.setStatusCode(400);
response.end();
return;
}
} catch (NumberFormatException e) {
response.setStatusCode(400);
response.end();
return;
}
Guild guild = DiscordUtils.getGuildFromBot(bot, guildId);
if (guild == null) {
response.setStatusCode(404);
response.end();
return;
}
TextChannel channel = guild.getTextChannelById(channelId);
if (channel == null) {
response.setStatusCode(403);
response.end();
return;
}
Member member = guild.getMemberById(userId);
if (member == null) {
response.setStatusCode(403);
response.end();
return;
}
if (!member.hasPermission(channel, Permission.MESSAGE_READ)) {
response.setStatusCode(403);
response.end();
return;
}
SettingsRecord settings = DatabaseUtils.getGuildSettings(database, guild);
if (!settings.getStatistics()) {
response.setStatusCode(404);
response.end();
return;
}
Gson gson = new Gson();
List<Stat> stats = Stat.getChannelMessageStats(database, guildId, channelId, from, to, 60);
response.putHeader("Content-Type", "application/json");
response.end(gson.toJson(stats, stats.getClass()));
}
示例12: handle
import io.vertx.core.http.HttpServerRequest; //导入方法依赖的package包/类
@Override
public void handle(RoutingContext ctx, Server server, DiscordBot bot, DSLContext database) {
HttpServerRequest request = ctx.request();
HttpServerResponse response = ctx.response();
String userId = ServerUtils.authUser(request, response, config);
if (userId == null) {
return;
}
String guildId = request.getParam("guildId");
String fromParam = request.getParam("from");
String toParam = request.getParam("to");
long from;
long to;
try {
from = Long.parseLong(fromParam);
to = Long.parseLong(toParam);
if (from <= 0 || to <= 0 || from >= to) {
response.setStatusCode(400);
response.end();
return;
}
} catch (NumberFormatException e) {
response.setStatusCode(400);
response.end();
return;
}
Guild guild = DiscordUtils.getGuildFromBot(bot, guildId);
if (guild == null) {
response.setStatusCode(404);
response.end();
return;
}
Member member = guild.getMemberById(userId);
if (member == null) {
response.setStatusCode(403);
response.end();
return;
}
SettingsRecord settings = DatabaseUtils.getGuildSettings(database, guild);
if (!settings.getStatistics()) {
response.setStatusCode(404);
response.end();
return;
}
Map<String, List<Stat>> stats = guild.getTextChannels()
.stream()
.filter((channel) -> member.hasPermission(channel, Permission.MESSAGE_READ))
.collect(Collectors.toMap((channel) -> channel.getId(), (channel) -> Stat.getChannelMessageStats(database, guildId, channel.getId(), from, to, 60)));
if (stats.isEmpty()) {
response.setStatusCode(403);
response.end();
return;
}
Gson gson = new Gson();
response.putHeader("Content-Type", "application/json");
response.end(gson.toJson(stats, stats.getClass()));
}
示例13: handle
import io.vertx.core.http.HttpServerRequest; //导入方法依赖的package包/类
@Override
public void handle(RoutingContext ctx, Server server, DiscordBot bot, DSLContext database) {
HttpServerRequest request = ctx.request();
HttpServerResponse response = ctx.response();
String userId = ServerUtils.authUser(request, response, config);
if (userId == null) {
return;
}
String guildId = request.getParam("guildId");
String fromParam = request.getParam("from");
String toParam = request.getParam("to");
long from;
long to;
try {
from = Long.parseLong(fromParam);
to = Long.parseLong(toParam);
if (from <= 0 || to <= 0 || from >= to) {
response.setStatusCode(400);
response.end();
return;
}
} catch (NumberFormatException e) {
response.setStatusCode(400);
response.end();
return;
}
Guild guild = DiscordUtils.getGuildFromBot(bot, guildId);
if (guild == null) {
response.setStatusCode(404);
response.end();
return;
}
Member member = guild.getMemberById(userId);
if (member == null) {
response.setStatusCode(403);
response.end();
return;
}
SettingsRecord settings = DatabaseUtils.getGuildSettings(database, guild);
if (!settings.getStatistics()) {
response.setStatusCode(404);
response.end();
return;
}
Gson gson = new Gson();
response.putHeader("Content-Type", "application/json");
response.end(gson.toJson(Stat.getGuildMessageStats(database, guildId, from, to, 60), new TypeToken<List<Stat>>() {}.getType()));
}
示例14: handle
import io.vertx.core.http.HttpServerRequest; //导入方法依赖的package包/类
@Override
public void handle(RoutingContext ctx, Server server, DiscordBot bot, DSLContext database) {
HttpServerRequest request = ctx.request();
HttpServerResponse response = ctx.response();
String code = request.getParam("code");
if (code == null) {
response.setStatusCode(400);
response.end();
return;
}
DiscordSecrets secrets = DiscordApiUtils.getUserSecrets(config, code);
if (secrets == null || !secrets.scope.equals("guilds identify")) {
response.setStatusCode(400);
response.end();
return;
}
SelfUser self = DiscordApiUtils.getSelf(secrets.accessToken);
if (self == null) {
response.setStatusCode(400);
response.end();
return;
}
Long now = (new Date().getTime()) / 1000;
OauthsecretsRecord record = database.newRecord(Tables.OAUTHSECRETS);
record.setUserid(self.id);
record.setAccesstoken(secrets.accessToken);
record.setRefreshtoken(secrets.refreshToken);
record.setExpirationdate(now + secrets.expiresIn);
database.insertInto(Tables.OAUTHSECRETS)
.set(record)
.onDuplicateKeyUpdate()
.set(record)
.execute();
String token = getJwtToken(self.id);
response.putHeader("Content-Type", "application/json");
response.end("\"" + token + "\"");
}