Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
4eaedae0
Commit
4eaedae0
authored
Sep 01, 2022
by
Melledy
Browse files
Move the remaining `HttpUtils` function over to `Router`
parent
fee34c51
Changes
10
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/server/http/HttpServer.java
View file @
4eaedae0
...
...
@@ -3,7 +3,6 @@ package emu.grasscutter.server.http;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.Grasscutter.ServerDebugMode
;
import
emu.grasscutter.utils.FileUtils
;
import
emu.grasscutter.utils.HttpUtils
;
import
io.javalin.Javalin
;
import
io.javalin.core.util.JavalinLogger
;
import
io.javalin.http.ContentType
;
...
...
src/main/java/emu/grasscutter/server/http/Router.java
View file @
4eaedae0
package
emu.grasscutter.server.http
;
import
io.javalin.Javalin
;
import
io.javalin.http.Handler
;
/**
* Defines routes for an {@link Javalin} instance.
...
...
@@ -12,4 +13,21 @@ public interface Router {
* @param javalin A Javalin instance.
*/
void
applyRoutes
(
Javalin
javalin
);
/**
* Applies this handler to all endpoint types
* @param javalin A Javalin instance.
* @param path
* @param ctx
* @return The Javalin instance.
*/
public
default
Javalin
allRoutes
(
Javalin
javalin
,
String
path
,
Handler
ctx
)
{
javalin
.
get
(
path
,
ctx
);
javalin
.
post
(
path
,
ctx
);
javalin
.
put
(
path
,
ctx
);
javalin
.
patch
(
path
,
ctx
);
javalin
.
delete
(
path
,
ctx
);
return
javalin
;
}
}
src/main/java/emu/grasscutter/server/http/documentation/GachaMappingRequestHandler.java
View file @
4eaedae0
package
emu.grasscutter.server.http.documentation
;
import
emu.grasscutter.tools.Tools
;
import
emu.grasscutter.utils.HttpUtils
;
import
emu.grasscutter.utils.Language
;
import
io.javalin.http.ContentType
;
import
io.javalin.http.Context
;
...
...
src/main/java/emu/grasscutter/server/http/documentation/HandbookRequestHandler.java
View file @
4eaedae0
...
...
@@ -10,7 +10,6 @@ import emu.grasscutter.data.excels.ItemData;
import
emu.grasscutter.data.excels.MonsterData
;
import
emu.grasscutter.data.excels.SceneData
;
import
emu.grasscutter.utils.FileUtils
;
import
emu.grasscutter.utils.HttpUtils
;
import
emu.grasscutter.utils.Language
;
import
emu.grasscutter.utils.Utils
;
import
io.javalin.http.ContentType
;
...
...
src/main/java/emu/grasscutter/server/http/documentation/RootRequestHandler.java
View file @
4eaedae0
...
...
@@ -5,7 +5,6 @@ import static emu.grasscutter.utils.Language.translate;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.utils.FileUtils
;
import
emu.grasscutter.utils.HttpUtils
;
import
emu.grasscutter.utils.Utils
;
import
io.javalin.http.ContentType
;
import
io.javalin.http.Context
;
...
...
src/main/java/emu/grasscutter/server/http/handlers/AnnouncementsHandler.java
View file @
4eaedae0
...
...
@@ -5,7 +5,6 @@ import emu.grasscutter.data.DataLoader;
import
emu.grasscutter.server.http.objects.HttpJsonResponse
;
import
emu.grasscutter.server.http.Router
;
import
emu.grasscutter.utils.FileUtils
;
import
emu.grasscutter.utils.HttpUtils
;
import
emu.grasscutter.utils.Utils
;
import
io.javalin.Javalin
;
import
io.javalin.http.ContentType
;
...
...
@@ -23,15 +22,15 @@ import java.util.Objects;
public
final
class
AnnouncementsHandler
implements
Router
{
@Override
public
void
applyRoutes
(
Javalin
javalin
)
{
// hk4e-api-os.hoyoverse.com
HttpUtil
s
.
allRoutes
(
javalin
,
"/common/hk4e_global/announcement/api/getAlertPic"
,
new
HttpJsonResponse
(
"{\"retcode\":0,\"message\":\"OK\",\"data\":{\"total\":0,\"list\":[]}}"
));
thi
s
.
allRoutes
(
javalin
,
"/common/hk4e_global/announcement/api/getAlertPic"
,
new
HttpJsonResponse
(
"{\"retcode\":0,\"message\":\"OK\",\"data\":{\"total\":0,\"list\":[]}}"
));
// hk4e-api-os.hoyoverse.com
HttpUtil
s
.
allRoutes
(
javalin
,
"/common/hk4e_global/announcement/api/getAlertAnn"
,
new
HttpJsonResponse
(
"{\"retcode\":0,\"message\":\"OK\",\"data\":{\"alert\":false,\"alert_id\":0,\"remind\":true}}"
));
thi
s
.
allRoutes
(
javalin
,
"/common/hk4e_global/announcement/api/getAlertAnn"
,
new
HttpJsonResponse
(
"{\"retcode\":0,\"message\":\"OK\",\"data\":{\"alert\":false,\"alert_id\":0,\"remind\":true}}"
));
// hk4e-api-os.hoyoverse.com
HttpUtil
s
.
allRoutes
(
javalin
,
"/common/hk4e_global/announcement/api/getAnnList"
,
AnnouncementsHandler:
:
getAnnouncement
);
thi
s
.
allRoutes
(
javalin
,
"/common/hk4e_global/announcement/api/getAnnList"
,
AnnouncementsHandler:
:
getAnnouncement
);
// hk4e-api-os-static.hoyoverse.com
HttpUtil
s
.
allRoutes
(
javalin
,
"/common/hk4e_global/announcement/api/getAnnContent"
,
AnnouncementsHandler:
:
getAnnouncement
);
thi
s
.
allRoutes
(
javalin
,
"/common/hk4e_global/announcement/api/getAnnContent"
,
AnnouncementsHandler:
:
getAnnouncement
);
// hk4e-sdk-os.hoyoverse.com
HttpUtil
s
.
allRoutes
(
javalin
,
"/hk4e_global/mdk/shopwindow/shopwindow/listPriceTier"
,
new
HttpJsonResponse
(
"{\"retcode\":0,\"message\":\"OK\",\"data\":{\"suggest_currency\":\"USD\",\"tiers\":[]}}"
));
thi
s
.
allRoutes
(
javalin
,
"/hk4e_global/mdk/shopwindow/shopwindow/listPriceTier"
,
new
HttpJsonResponse
(
"{\"retcode\":0,\"message\":\"OK\",\"data\":{\"suggest_currency\":\"USD\",\"tiers\":[]}}"
));
javalin
.
get
(
"/hk4e/announcement/*"
,
AnnouncementsHandler:
:
getPageResources
);
}
...
...
src/main/java/emu/grasscutter/server/http/handlers/GachaHandler.java
View file @
4eaedae0
...
...
@@ -8,7 +8,6 @@ import emu.grasscutter.game.gacha.GachaSystem;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.server.http.Router
;
import
emu.grasscutter.utils.FileUtils
;
import
emu.grasscutter.utils.HttpUtils
;
import
emu.grasscutter.utils.Utils
;
import
io.javalin.Javalin
;
import
io.javalin.http.ContentType
;
...
...
src/main/java/emu/grasscutter/server/http/handlers/GenericHandler.java
View file @
4eaedae0
...
...
@@ -7,7 +7,6 @@ import emu.grasscutter.Grasscutter;
import
emu.grasscutter.server.http.objects.HttpJsonResponse
;
import
emu.grasscutter.server.http.Router
;
import
emu.grasscutter.server.http.objects.WebStaticVersionResponse
;
import
emu.grasscutter.utils.HttpUtils
;
import
io.javalin.Javalin
;
import
io.javalin.http.Context
;
...
...
@@ -18,9 +17,8 @@ public final class GenericHandler implements Router {
@Override
public
void
applyRoutes
(
Javalin
javalin
)
{
// hk4e-sdk-os.hoyoverse.com
javalin
.
get
(
"/hk4e_global/mdk/agreement/api/getAgreementInfos"
,
new
HttpJsonResponse
(
"{\"retcode\":0,\"message\":\"OK\",\"data\":{\"marketing_agreements\":[]}}"
));
// hk4e-sdk-os.hoyoverse.com
// this could be either GET or POST based on the observation of different clients
HttpUtils
.
allRoutes
(
javalin
,
"/hk4e_global/combo/granter/api/compareProtocolVersion"
,
new
HttpJsonResponse
(
"{\"retcode\":0,\"message\":\"OK\",\"data\":{\"modified\":true,\"protocol\":{\"id\":0,\"app_id\":4,\"language\":\"en\",\"user_proto\":\"\",\"priv_proto\":\"\",\"major\":7,\"minimum\":0,\"create_time\":\"0\",\"teenager_proto\":\"\",\"third_proto\":\"\"}}}"
));
// hk4e-sdk-os.hoyoverse.com (this could be either GET or POST based on the observation of different clients)
this
.
allRoutes
(
javalin
,
"/hk4e_global/combo/granter/api/compareProtocolVersion"
,
new
HttpJsonResponse
(
"{\"retcode\":0,\"message\":\"OK\",\"data\":{\"modified\":true,\"protocol\":{\"id\":0,\"app_id\":4,\"language\":\"en\",\"user_proto\":\"\",\"priv_proto\":\"\",\"major\":7,\"minimum\":0,\"create_time\":\"0\",\"teenager_proto\":\"\",\"third_proto\":\"\"}}}"
));
// api-account-os.hoyoverse.com
javalin
.
post
(
"/account/risky/api/check"
,
new
HttpJsonResponse
(
"{\"retcode\":0,\"message\":\"OK\",\"data\":{\"id\":\"none\",\"action\":\"ACTION_NONE\",\"geetest\":null}}"
));
...
...
@@ -36,11 +34,11 @@ public final class GenericHandler implements Router {
javalin
.
post
(
"/data_abtest_api/config/experiment/list"
,
new
HttpJsonResponse
(
"{\"retcode\":0,\"success\":true,\"message\":\"\",\"data\":[{\"code\":1000,\"type\":2,\"config_id\":\"14\",\"period_id\":\"6036_99\",\"version\":\"1\",\"configs\":{\"cardType\":\"old\"}}]}"
));
// log-upload-os.mihoyo.com
HttpUtil
s
.
allRoutes
(
javalin
,
"/log/sdk/upload"
,
new
HttpJsonResponse
(
"{\"code\":0}"
));
HttpUtil
s
.
allRoutes
(
javalin
,
"/sdk/upload"
,
new
HttpJsonResponse
(
"{\"code\":0}"
));
thi
s
.
allRoutes
(
javalin
,
"/log/sdk/upload"
,
new
HttpJsonResponse
(
"{\"code\":0}"
));
thi
s
.
allRoutes
(
javalin
,
"/sdk/upload"
,
new
HttpJsonResponse
(
"{\"code\":0}"
));
javalin
.
post
(
"/sdk/dataUpload"
,
new
HttpJsonResponse
(
"{\"code\":0}"
));
// /perf/config/verify?device_id=xxx&platform=x&name=xxx
HttpUtil
s
.
allRoutes
(
javalin
,
"/perf/config/verify"
,
new
HttpJsonResponse
(
"{\"code\":0}"
));
thi
s
.
allRoutes
(
javalin
,
"/perf/config/verify"
,
new
HttpJsonResponse
(
"{\"code\":0}"
));
// webstatic-sea.hoyoverse.com
javalin
.
get
(
"/admin/mi18n/plat_oversea/*"
,
new
WebStaticVersionResponse
());
...
...
src/main/java/emu/grasscutter/server/http/objects/WebStaticVersionResponse.java
View file @
4eaedae0
...
...
@@ -2,7 +2,6 @@ package emu.grasscutter.server.http.objects;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.utils.FileUtils
;
import
emu.grasscutter.utils.HttpUtils
;
import
io.javalin.http.ContentType
;
import
io.javalin.http.Context
;
import
io.javalin.http.Handler
;
...
...
src/main/java/emu/grasscutter/utils/HttpUtils.java
deleted
100644 → 0
View file @
fee34c51
package
emu.grasscutter.utils
;
import
io.javalin.Javalin
;
import
io.javalin.http.Handler
;
public
final
class
HttpUtils
{
public
static
Javalin
allRoutes
(
Javalin
javalin
,
String
path
,
Handler
ctx
)
{
javalin
.
get
(
path
,
ctx
);
javalin
.
post
(
path
,
ctx
);
javalin
.
put
(
path
,
ctx
);
javalin
.
patch
(
path
,
ctx
);
javalin
.
delete
(
path
,
ctx
);
return
javalin
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment