mirror of
https://github.com/teacat/chaturbate-dvr.git
synced 2025-10-29 16:59:59 +00:00
WIP
This commit is contained in:
46
handler/terminate_program.go
Normal file
46
handler/terminate_program.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
//=======================================================
|
||||
// Request & Response
|
||||
//=======================================================
|
||||
|
||||
type TerminateProgramRequest struct {
|
||||
}
|
||||
|
||||
type TerminateProgramResponse struct {
|
||||
}
|
||||
|
||||
//=======================================================
|
||||
// Factory
|
||||
//=======================================================
|
||||
|
||||
type TerminateProgramHandler struct {
|
||||
cli *cli.Context
|
||||
}
|
||||
|
||||
func NewTerminateProgramHandler(cli *cli.Context) *TerminateProgramHandler {
|
||||
return &TerminateProgramHandler{cli}
|
||||
}
|
||||
|
||||
//=======================================================
|
||||
// Handle
|
||||
//=======================================================
|
||||
|
||||
func (h *TerminateProgramHandler) Handle(c *gin.Context) {
|
||||
var req *TerminateProgramRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
log.Println("program terminated by user request, see ya 👋")
|
||||
os.Exit(0)
|
||||
}
|
||||
Reference in New Issue
Block a user