d718c5a372
CI / compile_and_lint (push) Failing after 0s
CI / docker_build (linux/amd64, -linux-amd64-duckdb, duckdb) (push) Failing after 0s
CI / docker_build (linux/arm64, -linux-arm64, minimal) (push) Failing after 2s
CI / docker_build (linux/arm64, -linux-arm64-duckdb, duckdb) (push) Failing after 1s
CI / docker_build (linux/amd64, minimal) (push) Failing after 1s
CI / test (, sqlite, sqlite::memory:) (push) Has been skipped
CI / test (mssql, mssql, mssql://root:Password123!@127.0.0.1/sqlpage) (push) Has been skipped
CI / test (mysql, mysql, mysql://root:Password123!@127.0.0.1/sqlpage) (push) Has been skipped
CI / test (oracle, oracle, Driver=Oracle 21 ODBC driver;Dbq=//127.0.0.1:1521/FREEPDB1;Uid=root;Pwd=Password123!) (push) Has been skipped
CI / test (postgres, odbc, Driver=PostgreSQL Unicode;Server=127.0.0.1;Port=5432;Database=sqlpage;UID=root;PWD=Password123!, true) (push) Has been skipped
CI / test (postgres, postgres, postgres://root:Password123!@127.0.0.1/sqlpage) (push) Has been skipped
CI / playwright (push) Has been skipped
CI / docker_build (linux/arm/v7, -linux-arm-v7, minimal) (push) Failing after 0s
CI / hurl_examples (push) Failing after 8s
deploy website / deploy_official_site (push) Failing after 1s
CI / hurl (${{ matrix.example }}) (push) Has been skipped
CI / docker_push (duckdb) (push) Has been cancelled
CI / docker_push (minimal) (push) Has been cancelled
CI / windows_test (push) Has been cancelled
66 lines
1.9 KiB
SQL
66 lines
1.9 KiB
SQL
-- Insert the status_code component into the component table
|
|
INSERT INTO
|
|
component (name, description, icon)
|
|
VALUES
|
|
(
|
|
'status_code',
|
|
'Sets the HTTP response code for the current page.
|
|
|
|
This is an advanced technical component.
|
|
You typically need it when building internet-facing APIs and websites,
|
|
but you may not need it for simple internal applications.
|
|
|
|
- Indicating operation results when using [SQLPage as an API](?component=json)
|
|
- `200`: *OK*, for successful operations
|
|
- `201`: *Created*, for successful record insertion
|
|
- `404`: *Not Found*, for missing resources
|
|
- `500`: *Internal Server Error*, for failed operations
|
|
- Handling data validation errors
|
|
- `400`: *Bad Request*, for invalid data
|
|
- Enforcing access controls
|
|
- `403`: *Forbidden*, for unauthorized access
|
|
- `401`: *Unauthorized*, for unauthenticated access
|
|
- Tracking system health
|
|
- `500`: *Internal Server Error*, for failed operations
|
|
|
|
For search engine optimization:
|
|
- Use `404` for deleted content to remove outdated URLs from search engines
|
|
- For redirection from one page to another, use
|
|
- `301` (moved permanently), or
|
|
- `302` (moved temporarily)
|
|
- Use `503` during maintenance',
|
|
'error-404'
|
|
);
|
|
|
|
-- Insert the parameters for the status_code component into the parameter table
|
|
INSERT INTO
|
|
parameter (
|
|
component,
|
|
name,
|
|
description,
|
|
type,
|
|
top_level,
|
|
optional
|
|
)
|
|
VALUES
|
|
(
|
|
'status_code',
|
|
'status',
|
|
'HTTP status code (e.g., 200 OK, 401 Unauthorized, 409 Conflict)',
|
|
'INTEGER',
|
|
TRUE,
|
|
FALSE
|
|
);
|
|
|
|
INSERT INTO example (component, description)
|
|
VALUES (
|
|
'status_code',
|
|
'
|
|
Set the HTTP status code to 404, indicating that the requested resource was not found.
|
|
Useful in combination with [`404.sql` files](/your-first-sql-website/custom_urls.sql):
|
|
|
|
```sql
|
|
SELECT ''status_code'' as component, 404 as status;
|
|
```
|
|
');
|