How PageRoute handles a request
Flowchart from the Technical Manual.
Text version
- GET request for a page
- Page module imported?
- initialise() imports the page module
- Exports authorise?
- yes: Throw error
- no: Default export
- Throw error
- Default export
- class extending kitten.Page: Exports a function whose name matches /^on[A-Z]/?
- other class: Throw error
- function: Exports a name matching /^on[A-Z]/?
- none: Throw error
- Exports a function whose name matches /^on[A-Z]/?
- yes: Throw error
- no: Class-based, live
- Throw error
- Class-based, live
- Throw error
- Exports a name matching /^on[A-Z]/?
- Throw error
- Function-based, live
- Function-based, not live
- this.url = request.url
- isLive?
- storeSessionNow(request, response)
- Create the page: new subclass, or KittenPage with html() = default export
- Record the route on the page, start its connection timer when the response finishes or closes
- response.writableEnded?
- Start the connection timer
- Done
- page.html({ page, request, response })
- default export({ page: null, request, response })
- response.writableEnded?
- yes: Done
- no: Result undefined?
- Result undefined?
- Throw error
- renderHtml(): HTML document, libraries, slots, and styles, plus ws-connect on live pages
- 200 text/html
- countStat('pages', path)