gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Main branchmain5d144817Merge branch 'records-t40' into mainTicketsmain/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

  • 5d144817Merge branch 'records-t40' into mainTickets
  • 44ee6f06|||PR records: #43 #45 livemre
  • b8fdeee9Merge branch 'p39-routes' into mainTickets
  • a0187a0a|||PR Remove redundant route-order loopmre
  • 369e4b9cMerge branch 'k40-lists' into mainTickets
  • 9af8e780|||PR Use keyed list mutations for live ticket updatesmre
  • 610d8e8aMerge branch 'records-t39' into mainTickets
  • 32bcdf24|||PR records: GO P39 K40mre
  • 4123c6d1Merge branch 'records-t38' into mainTickets
  • cd3641a1|||PR records: day72 deploy live, tickets closedmre
  • 7d44d852Merge branch 'records-t37' into mainTickets
  • 926f7061|||PR records: merges, D36 deploymre
  • bf58534eMerge branch 'l33-final' into mainTickets
  • 759a9ac3|||PR thin login (tickets#46, #45): merge main, route entry cleanupmre
  • 239436d8Merge remote-tracking branch 'origin/main' into l33-finalmre
  • 5822cb3aMerge branch 'o34-clean' into mainTickets
  • 0870653c|||PR offline note from __hlOnline, no polling (tickets#41)mre
  • 14cf96b4Merge branch 'records-t36' into mainTickets
  • 07749fa1|||PR records: day72 + #40 mergedmre
  • ecd7e226|||PR Consolidate login and move handler logic into topic libraries (partial)mre