From 1bf5125b3fbd3b8fbcfae5a11093019f5e62dee4 Mon Sep 17 00:00:00 2001 From: ekwuno Date: Sun, 5 Jan 2025 18:57:49 +0000 Subject: [PATCH] Functions not endpoints --- .../doc-surrealdb/integration/http.mdx | 14 -------------- .../doc-surrealql/functions/database/http.mdx | 19 ++++++++++++++++++- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/content/doc-surrealdb/integration/http.mdx b/src/content/doc-surrealdb/integration/http.mdx index 84fbf2cf9..abc5e5e4a 100644 --- a/src/content/doc-surrealdb/integration/http.mdx +++ b/src/content/doc-surrealdb/integration/http.mdx @@ -29,20 +29,6 @@ The most convenient way to access these endpoints is via SurrealDB's Postman Col > [!IMPORTANT] > Ensure that your URL is set correctly, if running locally, the URL should be `http://localhost:8000`.By default, the URL is set to local. Start your server using the [`surreal start`](/docs/surrealdb/cli/start) command in the CLI or through Surrealist's [local database serving](/docs/surrealist/concepts/local-database-serving) functionality, before querying the endpoints. -## Before you begin - - - -From version `2.2` of SurrealDB, the HTTP endpoints have been improved to provide a more consistent and user-friendly experience. These improvements include: - -- **Enhanced HTTP error messages**: The server provides more descriptive error responses, including relevant HTTP status codes and detailed error information when available. - -- **Raw SurrealQL data encoding**: Data types are preserved more faithfully in responses through improved encoding. - - SurrealQL **byte values** are now sent as raw bytes (not base64-encoded or JSON-encoded). - - SurrealQL **string values** are sent as raw strings. - - All other SurrealQL values (numbers, arrays, objects, booleans, etc.) are automatically JSON-encoded. - -- **Removal of `Content-Type: application/octet-stream`**: SurrealDB no longer automatically adds `Content-Type: application/octet-stream` to responses when the body contains SurrealQL byte values. If you need this header, you can set it manually. ## Supported methods diff --git a/src/content/doc-surrealql/functions/database/http.mdx b/src/content/doc-surrealql/functions/database/http.mdx index 07f650db7..3cf0a7a6b 100644 --- a/src/content/doc-surrealql/functions/database/http.mdx +++ b/src/content/doc-surrealql/functions/database/http.mdx @@ -4,6 +4,7 @@ sidebar_label: HTTP functions title: HTTP functions | SurrealQL description: These functions can be used when opening and submitting remote web requests, and webhooks. --- +import Since from '@components/shared/Since.astro'; # HTTP functions @@ -44,6 +45,22 @@ These functions can be used when opening and submitting remote web requests, and + +## Before you begin + + + +From version `2.2` of SurrealDB, the HTTP functions have been improved to provide a more consistent and user-friendly experience. These improvements include: + +- **Enhanced HTTP error messages**: The server provides more descriptive error responses, including relevant HTTP status codes and detailed error information when available. + +- **Raw SurrealQL data encoding**: Data types are preserved more faithfully in responses through improved encoding. + - SurrealQL **byte values** are now sent as raw bytes (not base64-encoded or JSON-encoded). + - SurrealQL **string values** are sent as raw strings. + - All other SurrealQL values (numbers, arrays, objects, booleans, etc.) are automatically JSON-encoded. + +- **Removal of `Content-Type: application/octet-stream`**: SurrealDB no longer automatically adds `Content-Type: application/octet-stream` to responses when the body contains SurrealQL byte values. If you need this header, you can set it manually. + ## `http::head` The `http::head` function performs a remote HTTP `HEAD` request. The first parameter is the URL of the remote endpoint. If the response does not return a `2XX` status code, then the function will fail and return the error. @@ -197,7 +214,7 @@ The `http::patch` function performs a remote HTTP `PATCH` request. The first par ```surql title="API DEFINITION" http::patch(string, object) -> value ``` -If an object is given as the second argument, then this can be used to set the request headers. +If an object is given as the third argument, then this can be used to set the request headers. ```surql title="API DEFINITION" http::patch(string, object, object) -> value