An open API service indexing awesome lists of open source software.

https://github.com/sla-ppy/gocusign

[F] Backend integration for (docu)ment (sign)ing made with (Go)
https://github.com/sla-ppy/gocusign

backend curl get golang http openapi post

Last synced: 4 months ago
JSON representation

[F] Backend integration for (docu)ment (sign)ing made with (Go)

Awesome Lists containing this project

README

          

# gocusign
HTTP Client which uses OpenAPI calls to communicate with an HTTP server, written in Go

Things I've learned from the project:
- HTTP network protocol, GET, POST
- JWAuth Bearer Token auth with HTTP POST is possible by addig a header to do that, aka. we send the token with each POST request
- HTTP Headers specify what information we are sending or expect to receive from server, we call them [media types](https://www.iana.org/assignments/media-types/media-types.xhtml#application) such as: application/json, application/pdf
- Marshal from Go data to multipart/form-data
- Marshal from Go data to JSON, unmarshaling JSON to Go

## Testing HTTP requests locally using netcat and curl
- Set baseUrl to localhost addr
- Even when the program crashes the requests till that point can be examined
- Important: Only HTTP works! HTTPS doesn't work

Terminal #0
```
nc -l -p 1234 -v | less -> nc/netcat [TCP/IP server testing tool], -l [listens on the port], -p [sets port], -v [return more info]
```
Terminal #1
```
curl http://127.0.0.1:1234/ -> make HTTP GET request to test
```

## Using the API's curl commands and comparing it locally
- If the API documentation includes example on the Curl on succesful api call in the correct format
- We can check against the curl ran locally as the example shows:
- This way essentially we are comparing the packet sent and the packet succesfully received by the server

![image](demo/curl_comparision.png)

- [Tutorials by Digitial Ocean on Golang](https://www.digitalocean.com/community/tutorials/how-to-use-json-in-go)
- [Reqbin for HTTP theory and more](https://reqbin.com/)
- [Swagger for viewing API docs such as .yaml (F1 in VScode)](https://swagger.io/)