gitoria

jukebox

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitdcca21abdcca21abjukebox#8 Move copies and queue logic into their topicsmredcca21ab/plugins/http1/tests/on-error-answers.hl

1.2 KB

  1. // #285: a fault abandons this request handler; Error supplies its answer.
  2. import { NativeHttpServer, Response } from 'hl:http1'
  3. import { env } from 'hl:proc'
  4. port = toNumber(env('HL_TEST_PORT'))
  5. s = new NativeHttpServer(port = port)
  6. on s.request(Hybrid req) {
  7. if (req.path == '/health') { return new Response('healthy') }
  8. hlOnFault((String located) => { echo('hook') })
  9. if (req.path == '/sent') { req.respond.call('send', 202, 'sent') }
  10. hlError('route:' + req.path)
  11. echo('UNREACHABLE')
  12. }
  13. on Error(Hybrid e) {
  14. if (e.phase != 'event' || e.request != true) { hlError('wrong request context') }
  15. echo('handled')
  16. if (e.message.includes('/fatal')) { hlError('error-handler-fault') }
  17. if (e.message.includes('/text')) { return 'fallback' }
  18. if (e.message.includes('/json')) { return { ok = true items = [1, 2] } }
  19. if (e.message.includes('/status')) {
  20. return new Response('unavailable', { status = 503 headers = { 'X-Fallback' = 'yes' } })
  21. }
  22. if (e.message.includes('/bytes')) { return new Response(toBytes('raw')) }
  23. if (e.message.includes('/empty')) { return '' }
  24. if (e.message.includes('/false')) { return false }
  25. if (e.message.includes('/zero')) { return 0 }
  26. if (e.message.includes('/sent')) { return 'second' }
  27. if (e.message.includes('/null')) { return null }
  28. }

Branches

Latest commits

  • dcca21abjukebox#8 Move copies and queue logic into their topicsmre
  • 10f8a8c8Merge branch 'code-order' into mainJukebox
  • 204fc828Merge branch 'day72' into mainJukebox
  • 95f5faae|||PR jukebox#7 Drop needless let declarationsmre
  • 33072bb5|||PR Record day72 gates and Chrome proofmre
  • 95f2cd73|||PR Use typed parent methods for screen playback and local server facesmre
  • 6422a020Sync media-player at 51c3818mre
  • b582ba1cVendor complete Hybriel day72 plugin setmre
  • 02dccbc9Merge branch 'records-1119' into mainJukebox
  • a39e1c23|||PR Records: missions 013-015, reconnect fix livemre
  • fc7db075Merge branch 'reconnect-retry' into mainJukebox
  • ac6f4c6fL2: plain declaration for a in pickedNextmre
  • 2f335086Review round 2: only an explicit queue pick drops pend (not the automatic advance); jb23 records every source changemre
  • 3eb6695fReview fixes: action generation, queue pick clears pend, Previous/Next retry the decided request, typed handlersmre
  • 7a53c0c2|||PR A tap lost to a dead socket plays after reconnect (mission 015)mre
  • 1f0cd77bMerge branch 'records-day41' into mainJukebox
  • 67be229f|||PR Records: day41 live (PR #4), mission 012, statusmre
  • 0bb027daconductor: caramboleyo is the user, not owner/creatorApollo
  • 04f5d9d5Merge branch 'day41' into mainJukebox
  • 8ed6da45|||PR README: media-player pin df9e7dfmre