Uses 2770K of libraries. Click here for Pure Java version (24060L/131K).
!7 concept Domain { S domain; S moduleLibID; bool mustBeEnabled; toString { ret super.toString() + " " + domain; } } cmodule2 Eleu3 > DynEleu { transient CRUD<Domain> domainCRUD; switchable bool verbose; switchable bool debugNanoHTTPD; switchable S sameSite; start { NanoHTTPD_debug = debugNanoHTTPD; dbIndexingCI(Domain, 'domain); uniqCI Domain(domain := "<default>"); domainCRUD = new CRUD(Domain); dm_registerAs eleuWithCRUD(); } visualize { var c = jtabs( "Main", super.visualize(), "Domains" := domainCRUD.visualize()); tablePopupMenu(domainCRUD.table(), voidfunc(JPopupMenu menu, int row) { Domain d = domainCRUD.selected(), ret if null; if (nempty(d.moduleLibID)) addMenuItem(menu, "Load module", rThreadEnter { dm_makeOrShow(d.moduleLibID) }); }); ret c; } @Override S moduleForDomain(S domain) { domain = dropAfterColon(domain); // drop port number for (Domain d : domainsInMatchingOrder()) { if (domainIsUnder_extended(domain, d.domain)) { S mod = findMod(d); if (verbose) print("Domain matched: " + domain + " / " + d.domain + " => " + mod); try answer mod; } else if (verbose) print("Domain not matched: " + domain + " / " + d.domain); } ret findMod(defaultDomain()); } Domain defaultDomain() { ret conceptWhereCI Domain(domain := "<default>"); } S findMod(Domain d) { if (d == null || empty(d.moduleLibID)) null; ret d.mustBeEnabled ? dm_findModuleWithParams(d.moduleLibID, enabled := true) : dm_findModule(d.moduleLibID); } ServeHttp_CookieHandler makeCookieHandler() { ServeHttp_CookieHandler cookieHandler = super.makeCookieHandler(); cookieHandler.metaParams = appendPrefixIfNempty("SameSite=", sameSite); ret cookieHandler; } // API Cl<Domain> domainsInMatchingOrder() { ret sortByCalculatedFieldICDesc( filter(list(Domain), d -> !eqic(d.domain, "<default>")), d -> reversed(d.domain)); } void addDomain(S domain, S moduleLibID, bool mustBeEnabled) { uniq Domain(+domain, +moduleLibID, +mustBeEnabled); } }
Began life as a copy of #1029618
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): bhatertpkbcr, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1032724 |
Snippet name: | Eleu with CRUD by domain - main web server module [backup before proxies] |
Eternal ID of this version: | #1032724/1 |
Text MD5: | ec50d1020d2538e6986c287cebc213d2 |
Transpilation MD5: | 205c599e6c77549483e674325032e949 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-03 23:14:41 |
Source code size: | 2282 bytes / 81 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 181 / 265 |
Referenced in: | -