| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 55ccee5 commit d28b204
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,41 @@ | |||
| 1 | + package main | ||
| 2 | + | ||
| 3 | + import ( | ||
| 4 | + "bytes" | ||
| 5 | + "encoding/json" | ||
| 6 | + "fmt" | ||
| 7 | + "io/ioutil" | ||
| 8 | + "log" | ||
| 9 | + "net/http" | ||
| 10 | + | ||
| 11 | + "github.com/palantir/stacktrace" | ||
| 12 | + ) | ||
| 13 | + | ||
| 14 | + func main() { | ||
| 15 | + client := http.Client{} | ||
| 16 | + for i := 0; i < 100; i++ { | ||
| 17 | + payload, err := json.Marshal(map[string]string{ | ||
| 18 | + "content": fmt.Sprintf("testing http api sample: [%d]", i), | ||
| 19 | + "from": "+37259139660", | ||
| 20 | + "to": "+37253517181", | ||
| 21 | + }) | ||
| 22 | + if err != nil { | ||
| 23 | + log.Fatal(stacktrace.Propagate(err, "cannot create json payload")) | ||
| 24 | + } | ||
| 25 | + response, err := client.Post("http://api.httpsms.com/messages/send", "application/json", bytes.NewBuffer(payload)) | ||
| 26 | + if err != nil { | ||
| 27 | + log.Fatal(stacktrace.Propagate(err, "cannot perform http request")) | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + if response.StatusCode != http.StatusOK { | ||
| 31 | + log.Fatal(stacktrace.NewError(fmt.Sprintf("status code [%d] is different from expected [%d]", response.StatusCode, http.StatusOK))) | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + responsePayload, err := ioutil.ReadAll(response.Body) | ||
| 35 | + if err != nil { | ||
| 36 | + log.Fatal(stacktrace.NewError(fmt.Sprintf("cannot read response"))) | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + log.Println(string(responsePayload)) | ||
| 40 | + } | ||
| 41 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,6 @@ import axios from '~/plugins/axios' | |||
| 3 | 3 | import { MessageThread } from '~/models/message-thread' | |
| 4 | 4 | import { Message } from '~/models/message' | |
| 5 | 5 | import { Heartbeat } from '~/models/heartbeat' | |
| 6 | - import { compile } from 'vue-template-compiler' | ||
| 7 | 6 | ||
| 8 | 7 | type State = { | |
| 9 | 8 | owner: string | |
| Back | FazBrowse Home | New Git URL |
0 commit comments