mirror of
https://github.com/SourceFellows/gobuch.git
synced 2025-08-03 21:22:17 +02:00
initial import
This commit is contained in:
3
microservices/http-retry/server/go.mod
Normal file
3
microservices/http-retry/server/go.mod
Normal file
@ -0,0 +1,3 @@
|
||||
module golang.source-fellows.com/samples/httpretry/server
|
||||
|
||||
go 1.13
|
0
microservices/http-retry/server/go.sum
Normal file
0
microservices/http-retry/server/go.sum
Normal file
26
microservices/http-retry/server/main.go
Normal file
26
microservices/http-retry/server/main.go
Normal 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)
|
||||
}
|
Reference in New Issue
Block a user