An experimental web framework where PostgreSQL does everything: routing, HTML, file storage, jobs and sessions.
fix_homepage_html.sql · 928 bytes · 21 lines
| 1 | -- Fix homepage to return HTML mime type instead of JSON |
| 2 | -- The issue is in the handle_request function - it needs to set html: true in the response |
| 3 | |
| 4 | UPDATE code_files |
| 5 | SET content = regexp_replace( |
| 6 | content, |
| 7 | -- Find the line that returns the homepage response |
| 8 | 'RETURN jsonb_build_object\(\s*''status'', 200,\s*''headers'', jsonb_build_object\(''Content-Type'', ''text/html''\),\s*''body'', v_html\s*\);', |
| 9 | -- Replace with version that includes html flag |
| 10 | E'RETURN jsonb_build_object(\n ''status'', 200,\n ''headers'', jsonb_build_object(''Content-Type'', ''text/html''),\n ''body'', v_html,\n ''html'', true\n );', |
| 11 | 'g' |
| 12 | ), |
| 13 | version = version + 1, |
| 14 | updated_at = now() |
| 15 | WHERE path = 'functions/handle_request.sql'; |
| 16 | |
| 17 | -- Hot reload the function |
| 18 | SELECT hot_reload('functions/handle_request.sql'); |
| 19 | |
| 20 | -- Return status |
| 21 | SELECT 'Homepage fixed to return HTML!' as result; |