initial import

This commit is contained in:
SourceFellows
2020-08-21 06:26:40 +02:00
commit e223458dd4
423 changed files with 9871 additions and 0 deletions

View File

@ -0,0 +1,5 @@
module golang.source-fellows.com/samples/rfc7808/server
go 1.13
require github.com/hashicorp/go-retryablehttp v0.6.6

View File

@ -0,0 +1,8 @@
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM=
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
github.com/hashicorp/go-retryablehttp v0.6.6 h1:HJunrbHTDDbBb/ay4kxa1n+dLmttUlnP3V9oNE4hmsM=
github.com/hashicorp/go-retryablehttp v0.6.6/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=

View File

@ -0,0 +1,21 @@
package main
import (
"log"
"github.com/hashicorp/go-retryablehttp"
)
func main() {
retryClient := retryablehttp.NewClient()
retryClient.RetryMax = 10
standardClient := retryClient.StandardClient()
res, err := standardClient.Get("http://localhost:8080/")
if err != nil {
log.Fatal("could not request")
}
defer res.Body.Close()
log.Println(res.Status)
}

View File

@ -0,0 +1,3 @@
module golang.source-fellows.com/samples/httpretry/server
go 1.13

View File

View File

@ -0,0 +1,26 @@
package main
import (
"fmt"
"net/http"
)
var count int = 0
func handleHttp(res http.ResponseWriter, req *http.Request) {
responseStatus := http.StatusInternalServerError
if count%4 == 0 {
responseStatus = http.StatusOK
}
fmt.Printf("will return %v\n", responseStatus)
res.WriteHeader(responseStatus)
count++
}
func main() {
http.HandleFunc("/", handleHttp)
http.ListenAndServe(":8080", nil)
}