Skip to content

Commit

Permalink
remove go code snippets to prevent merge conflicts with #1262
Browse files Browse the repository at this point in the history
  • Loading branch information
choir241 committed Aug 22, 2024
1 parent 7253a09 commit f2155ac
Showing 1 changed file with 0 additions and 127 deletions.
127 changes: 0 additions & 127 deletions src/routes/docs/products/functions/develop/+page.markdoc
Original file line number Diff line number Diff line change
Expand Up @@ -206,56 +206,6 @@ export default ({ req, res, log, error }: any) => {
});
};
```

```go
package handler

import (
"fmt"
"os"

"github.com/appwrite/sdk-for-go/appwrite"
"github.com/open-runtimes/types-for-go/v4/openruntimes"
)

type Response struct {
Motto string `json:"motto"`
Learn string `json:"learn"`
Connect string `json:"connect"`
GetInspired string `json:"getInspired"`
}

func Main(Context openruntimes.Context) openruntimes.Response {
// This is your Appwrite function
// It's executed each time we get a request service
var _ = appwrite.NewClient(
appwrite.WithProject(os.Getenv("APPWRITE_FUNCTION_PROJECT_ID")),
appwrite.WithKey(Context.Req.Headers["x-appwrite-key"]),
)

// You can log messages to the console
fmt.Println("Hello, Logs!")

fmt.Fprintln(os.Stderr, "Error:", "Hello, Errors!")

// The `Context.Req` object contains the request data
if Context.Req.Method == "GET" {
// Send a response with the Context.Res object helpers
// `Context.Res.Text()` dispatches a string back to the client
return Context.Res.Text("Hello, World!")
}

// `res.json()` is a handy helper for sending JSON
return Context.Res.Json(
Response{
Motto: "Build like a team of hundreds_",
Learn: "https://appwrite.io/docs",
Connect: "https://appwrite.io/discord",
GetInspired: "https://builtwith.appwrite.io",
})
}
```

```dart
import 'dart:async';
import 'package:dart_appwrite/dart_appwrite.dart';
Expand Down Expand Up @@ -1554,42 +1504,6 @@ export default function ({req, res, error}: any){
return res.text("Document created");
}
```
```go
package handler

import (
"os"
"fmt"

"github.com/appwrite/sdk-for-go/appwrite"
"github.com/appwrite/sdk-for-go/id"
"github.com/open-runtimes/types-for-go/v4/openruntimes"
)

func Main(Context openruntimes.Context) openruntimes.Response {
// Set project and set API key
client := appwrite.NewClient(
appwrite.WithProject(os.Getenv("APPWRITE_FUNCTION_PROJECT_ID")),
appwrite.WithKey(Context.Req.Headers["x-appwrite-key"]),
)

databases := appwrite.NewDatabases(client)

_, err := databases.CreateDocument(
"<DATABASE_ID>",
"<COLLECTION_ID>",
id.Unique(),
map[string]interface{}{},
)

if err != nil {
Context.Log(fmt.Sprintf("Failed to create document: %v", err))
return Context.Res.Text("Failed to create document")
}

return Context.Res.Text("Document created")
}
```
```dart
import 'dart:io';
import 'dart:async';
Expand Down Expand Up @@ -1916,47 +1830,6 @@ export default function ({req, res, error}: any){
return res.text("Document created");
}
```
```go
package handler

import (
"fmt"
"log"

"github.com/appwrite/sdk-for-go/appwrite"
"github.com/appwrite/sdk-for-go/id"
"github.com/open-runtimes/types-for-go/v4/openruntimes"
)

func Main(Context openruntimes.Context) openruntimes.Response {
client := appwrite.NewClient(
appwrite.WithProject("<PROJECT_ID>"),
)

jwt, exists := Context.Req.Headers["x-appwrite-user-jwt"]
if !exists || len(jwt) == 0 {
appwrite.WithJWT(Context.Req.Headers["x-appwrite-user-jwt"])
} else {
return Context.Res.Text("Please sign in, JWT not found")
}

databases := appwrite.NewDatabases(client)

_, err := databases.CreateDocument(
"<DATABASE_ID>",
"<COLLECTION_ID>",
id.Unique(),
map[string]interface{}{},
)

if err != nil {
Context.Log(fmt.Sprintf("Failed to create document: %v", err))
return Context.Res.Text(str)
}

return Context.Res.Text("Document created")
}
```
```dart
import 'dart:io';
import 'dart:async';
Expand Down

0 comments on commit f2155ac

Please sign in to comment.