Compare commits
No commits in common. "c0fea387908ca9db96d4b63968a3c9047d1c2260" and "0786a97a770c91bf9f7bdcce07046aac6368a607" have entirely different histories.
c0fea38790
...
0786a97a77
@ -58,7 +58,6 @@ func FooControllerHandler(ctx *framework.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func UserLoginController(ctx *framework.Context) error {
|
func UserLoginController(ctx *framework.Context) error {
|
||||||
time.Sleep(10 * time.Second)
|
|
||||||
ctx.WriteJSON(http.StatusOK, "ok")
|
ctx.WriteJSON(http.StatusOK, "ok")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
22
main.go
22
main.go
@ -1,13 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"os/signal"
|
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"git.vinchent.xyz/vinchent/go-web/framework"
|
"git.vinchent.xyz/vinchent/go-web/framework"
|
||||||
)
|
)
|
||||||
@ -20,20 +15,7 @@ func main() {
|
|||||||
Handler: core,
|
Handler: core,
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
if err := server.ListenAndServe(); err != nil {
|
||||||
server.ListenAndServe()
|
log.Panic(err)
|
||||||
}()
|
|
||||||
|
|
||||||
// create quit channel
|
|
||||||
quit := make(chan os.Signal, 1)
|
|
||||||
|
|
||||||
// set notifier
|
|
||||||
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
|
|
||||||
|
|
||||||
<-quit
|
|
||||||
fmt.Println("YOLO")
|
|
||||||
|
|
||||||
if err := server.Shutdown(context.Background()); err != nil {
|
|
||||||
log.Fatal("server shutdown: ", err)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user