Skip to content

Commit

Permalink
feat: adding golang snippet for request
Browse files Browse the repository at this point in the history
  • Loading branch information
axrav committed May 1, 2023
1 parent 1ef40e7 commit 451cdae
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,43 @@ print("Is spam:", result["is_spam"])
print("Spam probability:", result["spam_probability"])
```

### Go

```go
package main

import (
"bytes"
"encoding/json"
"net/http"
)

func main() {
url := "http://localhost:8000/spam_check"
data := map[string]string{"text": "subscribe to my youtube channel"}
jsonData, err := json.Marshal(data)
if err != nil {
panic(err)
}

req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
if err != nil {
panic(err)
}

req.Header.Set("Content-Type", "application/json")

client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()

// Do something with the response if needed
}
```

### Rust

```rust
Expand Down

0 comments on commit 451cdae

Please sign in to comment.