35 lines
712 B
Go
35 lines
712 B
Go
package main
|
|
|
|
import (
|
|
log "github.com/sirupsen/logrus"
|
|
"net/http"
|
|
"os"
|
|
)
|
|
|
|
func write_error(w http.ResponseWriter) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.WriteHeader(http.StatusOK)
|
|
jsonData := []byte(`{"status":"ERROR","reason":"bad request"}`)
|
|
w.Write(jsonData)
|
|
}
|
|
|
|
func main() {
|
|
log_level := os.Getenv("LOG_LEVEL")
|
|
|
|
if log_level == "DEBUG" {
|
|
log.SetLevel(log.DebugLevel)
|
|
}
|
|
|
|
log.SetFormatter(&log.JSONFormatter{
|
|
DisableHTMLEscape: true,
|
|
})
|
|
|
|
mux := http.NewServeMux()
|
|
|
|
mux.HandleFunc("/new", new_card_request)
|
|
mux.HandleFunc("/ln", lnurlw_response)
|
|
mux.HandleFunc("/cb", lnurlw_callback)
|
|
|
|
err := http.ListenAndServe(":9000", mux)
|
|
log.Fatal(err)
|
|
}
|