Skip to content

Commit

Permalink
add option to send message to server from file
Browse files Browse the repository at this point in the history
  • Loading branch information
ernesto27 committed Feb 13, 2024
1 parent e72b11c commit bcdc3f7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ Send query to graphql server
```bash
req -t gq -u https://countries.trevorblades.com/ -p 'query {countries {name}}'
```
Use file to send query
```bash
req -t gq -u https://countries.trevorblades.com/ -p @myfolder/query.txt
```


### GRPC

Expand All @@ -72,7 +77,7 @@ req -t grpc -u localhost:50051 -import-path /pathprotofiles/helloworld -proto he
| --- | --- |
| -u | url server |
| -m | http method |
| -p | data to send to server |
| -p | data to send to server in raw string of use @myfolder/file to send from file |
| -t | type protocol (http, ws, gq, grpc) defaut http |
| -q | http query params |
| -h | http headers |
Expand Down
14 changes: 14 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,20 @@ func main() {
download := flag.Bool("d", false, "download content")
flag.Parse()

if len(params.message) > 0 {
atSymbol := 64
if params.message[0] == byte(atSymbol) {
filePath := string(params.message[1:])

content, err := os.ReadFile(filePath)
if err != nil {
fmt.Println(styleErr.Render("Error reading file: " + err.Error()))
return
}
params.message = string(content)
}
}

validProtocos := []string{"ws", "gq", "http", "grpc"}

valid := false
Expand Down

0 comments on commit bcdc3f7

Please sign in to comment.