.
This commit is contained in:
parent
38e72e2a0c
commit
abe6ba4ed6
3 changed files with 4 additions and 6 deletions
3
main.go
3
main.go
|
|
@ -8,9 +8,6 @@ import (
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cfg := LoadConfig()
|
cfg := LoadConfig()
|
||||||
for _, relay := range cfg.Relays {
|
|
||||||
log.Printf(relay)
|
|
||||||
}
|
|
||||||
http.HandleFunc("/", alertReceiver)
|
http.HandleFunc("/", alertReceiver)
|
||||||
log.Printf("Server starting on http://localhost:%d", cfg.Port)
|
log.Printf("Server starting on http://localhost:%d", cfg.Port)
|
||||||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", cfg.Port), nil))
|
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", cfg.Port), nil))
|
||||||
|
|
|
||||||
2
nostr.go
2
nostr.go
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func sendAlerts(config Config, alert string) error {
|
func sendAlerts(config *Config, alert string) error {
|
||||||
|
|
||||||
pool := nostr.NewPool(nostr.PoolOptions{
|
pool := nostr.NewPool(nostr.PoolOptions{
|
||||||
PenaltyBox: true,
|
PenaltyBox: true,
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func alertReceiver(w http.ResponseWriter, r *http.Request) {
|
func alertReceiver(w http.ResponseWriter, r *http.Request) {
|
||||||
|
cfg := LoadConfig()
|
||||||
if r.Method != http.MethodPost {
|
if r.Method != http.MethodPost {
|
||||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||||
return
|
return
|
||||||
|
|
@ -25,6 +25,7 @@ func alertReceiver(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
payload := ParseAlert(body)
|
payload := ParseAlert(body)
|
||||||
fmt.Printf(payload)
|
publish := sendAlerts(cfg, payload)
|
||||||
|
check(publish)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue