using Invercargill; using Invercargill.DataStructures; using Statum; namespace UsmWeb { /** * Entrypoint for /repo/{name}: hydrates the * {@link PackagesState.SLOT_TYPE} PAGE slot scoped to one repository — * its overview card, add-repository instructions and package table. * Unknown repositories redirect to the overview; a load failure degrades * to an error card instead of a failed hydration. */ public class RepoBrowseEntrypoint : StatumEntrypoint { protected RepositoryService repositories = Inversion.inject(); protected UsmWebConfig config = Inversion.inject(); protected Astralis.HttpContext http_context = Inversion.inject(); public override async DirectiveBuilder handle() throws GLib.Error { var name = request.route("name") ?? ""; var base_uri = DerivedBase.derive(http_context.request, config); State state; try { if (repositories.find(name) == null) { return directives().navigate("/"); } state = PackagesState.build(repositories, config, action_registry, base_uri, "", name); } catch (Error e) { warning("[usm-web] Repository load failed: %s\n", e.message); var dict = new PropertyDictionary(); dict.set_native("load_error", e.message); state = new State() { type_name = PackagesState.SLOT_TYPE, public_data = dict, private_data = new PropertyDictionary() }; } return directives().set(state_service.new_slot(Scope.PAGE, state)); } } }