Skip to content

Commit

Permalink
Functions not endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Ekwuno committed Jan 5, 2025
1 parent 7e80267 commit 1bf5125
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
14 changes: 0 additions & 14 deletions src/content/doc-surrealdb/integration/http.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

<Since v="v2.2.0" />

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

Expand Down
19 changes: 18 additions & 1 deletion src/content/doc-surrealql/functions/database/http.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -44,6 +45,22 @@ These functions can be used when opening and submitting remote web requests, and
</tbody>
</table>


## Before you begin

<Since v="v2.2.0" />

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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1bf5125

Please sign in to comment.