Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A description of Hono Prepared Router

EdamAmex
December 20, 2024

A description of Hono Prepared Router

A description of Hono Prepared Router

EdamAmex

December 20, 2024
Tweet

Other Decks in Technology

Transcript

  1. Process of Build 1. Lexer Path 2. Generate Conditions 3.

    Rollup and Optimize 4. Dynamic Prediction
  2. 1. Lexer Path /book/:id /book/:id/:page{\\d+} /search/* separator static dynamic regex

    wildcard analyze the routing path 2. Generate Conditions pathParts is an array separated by separators. pathParts[1] = ‘book’ !!pathParts[2] ... /\d+/.test(pathParts[3]) ... pathParts.length > 2 ... And generate params
  3. 3. Rollup and Optimize if (A) { if (B) {

    ... } } if (C) { if (A) { ... } } optimize conditions if (A) { if (B) { ... } if (C) { ... } } if B and C are exclusive (B⊕C) if (A) { if (B) { ... }else if (C) { ... } }
  4. 4. Dynamic Prediction cache static path POST /books/list This is

    static path Routing with built matcher and cache the results const results = matcher(“POST”, “/books/list”, ...) // [/books/*, /books/list] cache(“POST”, “/books/list”, results)