Skip to content

Commit

Permalink
rename it :)
Browse files Browse the repository at this point in the history
  • Loading branch information
applegreengrape committed Nov 19, 2021
1 parent e4c564c commit ab269e4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
8 changes: 4 additions & 4 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
builds:
- id: darwin-amd64
main: ./
binary: wait
binary: checker-api
goos:
- darwin
goarch:
Expand All @@ -17,7 +17,7 @@ builds:
- -s -w -X main.version={{.Version}}
- id: linux-armhf
main: ./
binary: wait
binary: checker-api
goos:
- linux
goarch:
Expand Down Expand Up @@ -57,7 +57,7 @@ brews:
-
tap:
owner: applegreengrape
name: delay-api
name: timeout-checker
folder: Formula
homepage: https://github.com/applegreengrape/delay-api
homepage: https://github.com/applegreengrape/timeout-checker
description: simple wait& response api for timeout test
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# delay-api
simple wait for response api for timeout test
# timeout-checker
A simple wait and response api for retry& timeout test. Yes everyone loves to test retry and timeout 🤠

Install via brew
```
brew tap applegreengrape/delay-api https://github.com/applegreengrape/delay-api
brew install delay-api
brew tap applegreengrape/timeout-checker https://github.com/applegreengrape/timeout-checker
brew install timeout-checker
```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module wait
module checker-api

go 1.16

Expand Down
9 changes: 6 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/http"
"flag"
"time"
"log"

"github.com/gorilla/mux"
)
Expand All @@ -14,21 +15,23 @@ type Wait struct {
}

func (wait *Wait) healthcheck(w http.ResponseWriter, r *http.Request) {
fmt.Println("recieved")
log.Println("recieved")
time.Sleep(time.Duration(wait.time) * time.Second)

fmt.Println("returned")
w.WriteHeader(http.StatusOK)
w.Write([]byte(`{"status":"up"}`))
log.Println("returned")
}

func main() {
wait := flag.Int("wait", 3, "")
port := flag.Int("port", 8080, "")

flag.Parse()

w := &Wait{time: *wait}

router := mux.NewRouter().StrictSlash(true)
router.HandleFunc("/healthcheck", w.healthcheck).Methods("GET")
http.ListenAndServe(":8080", router)
http.ListenAndServe(fmt.Sprintf(":%d", *port), router)
}

0 comments on commit ab269e4

Please sign in to comment.