From inside a worker server, the only external hostname is "httpl://host.page"
To reach anything, the worker proxies through the hostpage.
"httpl://host.page/http%3A%2F%2Fexplorer%2F"
RESH, the REst SHell
A basic command:
GET foo/bar -Accept=text/html
Rewritten:
GET foo/bar [text/html]
// DATA STORE API | |
importScripts('/js/guip/jsondb-1.0.0.js'); | |
var data = guip.jsonDB(); | |
data.select(where, { order:, limit:, offset:, groupBy: }) | |
data.get(id) | |
data.getMeta(id) | |
data.insert(doc, meta, perms) | |
data.update(id|where, doc, meta, perms) | |
data.updateMeta(id|where, meta) |
User Agents are objects which wrap URLs which are known as the "location" or the "context." They fetch and cache the index from their location, then query the index's meta-data for links to new URLs. A new Agent is created to wrap the matching URL. It maintains a back-reference to its parent, and is known as having a "relative context."
Fetching the index is known as "resolution," and is triggered by the first resolve() or dispatch() call. If the Agent is relative, its parent may need resolution first, so the full ancestry is triggered to resolve in the process. The unresolve() function will clear the cache of the Agent so that it will re-resolve on its next dispatch.
It's useful for me to think of Agents as database cursors.
RUSH (sorry bri, I have to... for the Getty) has a syntax for specifying an Agent in its requests:
myagent> GET foobar-generator
A design rationale.
For the past fews years, the Web has been shifting control to the client. Given the limitations of remote services, developers are now looking for ways to "unhost" static applications – that is, break the dependency on remote servers while still using the Web platform.
One untapped technology for client-side control is the Web Worker Sandbox. This API lets the Page load, execute, and destroy separate Worker threads which use their own Virtual Machines. By using Worker Sandboxes to drive behavior, the Web can give users the choice of which software they run together, shifting development from a centralized SaaS model into a distributed and free (as in freedom) script-sharing model.
Worker Sandboxes can Execute Arbitrary Code
A design rationale.
See first: In-Application Sandboxing with Web Workers.
Web Workers interact with their Host Pages using a messaging channel (the postMessage
API). Crucially for their programming model, the messages are asyncronous. This introduces a significant challenge for implementing Page APIs within a Worker – for instance, how do you port a GUI widget from the Page (where it can access the DOM) to a Worker, where it can only send async messages?
In my experience, two categories of solutions are suggested: use code-transformations to recreate Page-native APIs in the Worker, or introduce a new interface around messaging. In this gist, I'll explain why code transformations don't address the problem fully, and present a complete messaging solution based on HTTP.
A design overview
Read first: In-Application Sandboxing with Web Workers. It explains the rationale behind using Web Workers.
And: Communicating with Workers using HTTP. It explains the rationale for choosing HTTP for messaging.
The TL;DR:
var myitems = []; | |
testserver.route('/protocol/crud-coll') | |
.link({ href: '/protocol/crud-coll', rel: 'self', title: 'My Collection' }) | |
.protocol('stdrel.com/crud-coll', { | |
itemUrl: '/protocol/crud-coll/{id}', | |
validate: function(item, req, res) { | |
var errors = {}; | |
if (!item.fname) errors.fname = 'Required.'; | |
if (!item.lname) errors.lname = 'Required.'; | |
return errors; |
// defining services | |
var usersCollection = []; | |
service Main { | |
link collection = Users; | |
meta rel = 'service'; | |
meta id = 'main'; | |
} | |
local.hostChannel.bind(Main); |