Expose bounded web contexts for embedded tools
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user