Skip to content

Commit

Permalink
only listen to /loki/api/v1/push
Browse files Browse the repository at this point in the history
  • Loading branch information
rucciva committed Jun 13, 2023
1 parent 092a25d commit 703df1d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ type data struct {
}

func main() {
http.ListenAndServe(":3100", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
http.HandleFunc("/loki/api/v1/push", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
w.WriteHeader(405)
return
}

req, err := push.ParseRequest(logger, "", r, nil)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
Expand Down Expand Up @@ -60,4 +65,6 @@ func main() {

w.WriteHeader(http.StatusNoContent)
}))

http.ListenAndServe(":3100", nil)
}

0 comments on commit 703df1d

Please sign in to comment.