Initial project structure, HTTP server
This commit is contained in:
parent
f2aeec4bdf
commit
c29a6832be
4 changed files with 53 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
matrix-alertmanager-receiver
|
12
Makefile
Normal file
12
Makefile
Normal file
|
@ -0,0 +1,12 @@
|
|||
NAME=matrix-alertmanager-receiver
|
||||
|
||||
all: build
|
||||
|
||||
getDeps:
|
||||
go get -v
|
||||
|
||||
build:
|
||||
go build
|
||||
|
||||
clean:
|
||||
rm $(NAME)
|
5
README.md
Normal file
5
README.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# matrix-alertmanager-receiver
|
||||
|
||||
TODO: synopsis, existing matrix-alermanager
|
||||
|
||||
See `matrix-alermanager-receiver.scd` for usage.
|
35
main.go
Normal file
35
main.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Initialize logger.
|
||||
var logger *log.Logger = log.New(os.Stdout, "", log.Flags())
|
||||
|
||||
// Handle command-line arguments.
|
||||
var port = flag.Int("port", 9088, "HTTP port to listen on (incoming alertmanager webhooks)")
|
||||
flag.Parse()
|
||||
|
||||
// Initialize Matrix client.
|
||||
// TODO
|
||||
|
||||
// Initialize HTTP serve (= listen for incoming requests).
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, `Hi! I receive prometheus-alertmanager webhooks on /alert and forward them to Matrix.
|
||||
|
||||
You will find more details on: http://git.sr.ht/~fnux/matrix-prometheus-alertmanager`)
|
||||
})
|
||||
|
||||
http.HandleFunc("/alert", func(w http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
|
||||
var listenAddr = fmt.Sprintf(":%v", *port)
|
||||
logger.Printf("Listening for HTTP requests (webhooks) on %v", listenAddr)
|
||||
log.Fatal(http.ListenAndServe(listenAddr, nil))
|
||||
}
|
Loading…
Reference in a new issue