Expose bounded web contexts for embedded tools

This commit is contained in:
2026-09-19 16:34:09 +03:00
parent bcd1a75a19
commit 625efc9fb3
3 changed files with 339 additions and 9 deletions
@@ -1,5 +1,7 @@
package online.astradev.packs;
import com.sun.net.httpserver.HttpHandler;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.Connection;
import net.minecraft.network.chat.Component;
@@ -169,6 +171,18 @@ public final class PackRuntime implements AutoCloseable {
return address.replaceAll("/+$", "") + host.issuePath(pack);
}
/** Mounts an editor or other web endpoint on AstraPacks' HTTP origin. */
public AutoCloseable mountWebContext(String prefix, HttpHandler handler) {
if (closed) {
throw new IllegalStateException("AstraPacks is closed");
}
return host.mountWebContext(prefix, handler);
}
public String publicUrl(String path) {
return host.publicUrl(config.hosting.publicAddress, path);
}
public void build(CommandSourceStack source) {
requestBuild(source, false);
}