Skip to content

Commit

Permalink
Merge pull request #588 from deniszh/dzhdanov/http
Browse files Browse the repository at this point in the history
Adding HTTP GET handler for health check
  • Loading branch information
deniszh authored Jun 6, 2024
2 parents 04bb3dc + 083e129 commit adcbb49
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ jobs:
- name: Set up Go tip
if: matrix.go == 'tip'
run: |
curl -sL https://storage.googleapis.com/go-build-snap/go/linux-amd64/$(git ls-remote https://github.com/golang/go.git HEAD | awk '{print $1;}').tar.gz -o gotip.tar.gz
ls -lah gotip.tar.gz
mkdir -p ~/sdk/gotip
tar -C ~/sdk/gotip -xzf gotip.tar.gz
~/sdk/gotip/bin/go version
curl -o go.tar.gz -L \
https://github.com/AlekSi/golang-tip/releases/download/tip/master.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go.tar.gz
sudo ln -s /usr/local/go/bin/* /usr/local/bin/
/usr/local/bin/go version
echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV
- name: Check out code into the Go module directory
Expand Down Expand Up @@ -59,12 +59,11 @@ jobs:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7' # Version range or exact version of a Ruby version to use, using semvers version range syntax.
ruby-version: '3.3'

- name: Install packaging dependencies
run: |
gem install dotenv -v 2.8.1
gem install rake fpm:1.10.2 package_cloud
gem install rake fpm package_cloud
go install github.com/mitchellh/gox@latest
- name: Check packaging
Expand Down
5 changes: 5 additions & 0 deletions receiver/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ func (rcv *HTTP) Stat(send helper.StatCallback) {
}

func (rcv *HTTP) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
http.Error(w, "OK", http.StatusOK)
return
}

if r.Method != "POST" {
atomic.AddUint32(&rcv.errors, 1)
http.Error(w, fmt.Sprintf("Method %#v is not supported", r.Method), http.StatusBadRequest)
Expand Down

0 comments on commit adcbb49

Please sign in to comment.