43 lines
777 B
Go
43 lines
777 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net/http"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
"time"
|
|
|
|
"git.0x0001f346.de/andreas/clickNgo/handler"
|
|
)
|
|
|
|
func main() {
|
|
sigChan := make(chan os.Signal, 1)
|
|
signal.Notify(sigChan, syscall.SIGINT)
|
|
|
|
server := &http.Server{
|
|
Addr: ":9666",
|
|
}
|
|
|
|
go func() {
|
|
http.HandleFunc("/", handler.GETIndex)
|
|
http.HandleFunc("/jdcheck.js", handler.GETJdcheckJS)
|
|
http.HandleFunc("/flash/add", handler.POSTFlashAdd)
|
|
http.HandleFunc("/flash/addcrypted2", handler.POSTFlashAddcrypted2)
|
|
|
|
if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
|
fmt.Printf("[Error] %v\n", err)
|
|
}
|
|
}()
|
|
|
|
<-sigChan
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
|
defer cancel()
|
|
|
|
server.Shutdown(ctx)
|
|
|
|
os.Exit(0)
|
|
}
|