Updated frontend to new Protocol
This commit is contained in:
@@ -1,49 +1,73 @@
|
||||
package ins.frontend;
|
||||
|
||||
import ins.frontend.utils.WebApp;
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.web.WebResponsePacket;
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.resource.WebResourceResponsePacket;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_1.beta.WebPacketFlags;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_1.beta.WebPacketHeader;
|
||||
import org.openautonomousconnection.webserver.api.Route;
|
||||
import org.openautonomousconnection.webserver.api.WebPage;
|
||||
import org.openautonomousconnection.webserver.api.WebPageContext;
|
||||
import org.openautonomousconnection.webserver.utils.HeaderMaps;
|
||||
import org.openautonomousconnection.webserver.utils.Html;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Landing page for the registrar ins.frontend.
|
||||
* Info page for INS registrar frontend (v1.0.1).
|
||||
*/
|
||||
@Route(path = "info.html")
|
||||
@Route(path = "/info.html")
|
||||
public final class info implements WebPage {
|
||||
|
||||
@Override
|
||||
public WebResponsePacket handle(WebPageContext ctx) {
|
||||
public WebResourceResponsePacket handle(WebPageContext ctx) {
|
||||
WebApp.init();
|
||||
|
||||
String html = Html.page("INS Info", """
|
||||
<section class="card">
|
||||
<section class="card">
|
||||
<h2>OAC Default INS Server</h2>
|
||||
|
||||
|
||||
<p>
|
||||
The <strong>Default INS Server</strong> is the official, project-operated
|
||||
name service of the Open Autonomous Connection (OAC) network.
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
It provides a trusted reference point for resolving InfoNames
|
||||
and enables initial client connections
|
||||
to the OAC ecosystem.
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
This server is maintained by the OAC project and is intended
|
||||
as the recommended entry point for public services and new clients.
|
||||
</p>
|
||||
|
||||
|
||||
<p class="muted">
|
||||
Note: Alternative or private INS servers may exist, but the default INS
|
||||
server represents the official and stable reference instance.
|
||||
</p>
|
||||
</section> """);
|
||||
</section>
|
||||
""");
|
||||
|
||||
return new WebResponsePacket(200, "text/html", new HashMap<>(), Html.utf8(html));
|
||||
byte[] body = Html.utf8(html);
|
||||
Map<String, String> headers = HeaderMaps.mutable();
|
||||
headers.put("content-length", String.valueOf(body.length));
|
||||
|
||||
return new WebResourceResponsePacket(outHeader(ctx), 200, "text/html; charset=utf-8", headers, body, null);
|
||||
}
|
||||
}
|
||||
|
||||
private WebPacketHeader outHeader(WebPageContext ctx) {
|
||||
WebPacketHeader in = (ctx != null && ctx.request != null) ? ctx.request.getHeader() : null;
|
||||
if (in == null) {
|
||||
return new WebPacketHeader(0, 0, 0, 0, WebPacketFlags.RESOURCE, System.currentTimeMillis());
|
||||
}
|
||||
return new WebPacketHeader(
|
||||
in.getRequestId(),
|
||||
in.getTabId(),
|
||||
in.getPageId(),
|
||||
in.getFrameId(),
|
||||
in.getFlags() | WebPacketFlags.RESOURCE,
|
||||
System.currentTimeMillis()
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user