Updated checking of server connection
This commit is contained in:
parent
cb05cf165e
commit
f112475823
1 changed files with 14 additions and 12 deletions
|
|
@ -51,7 +51,7 @@ func connect() {
|
|||
//SERVER
|
||||
// router.Use(cors.New(cors.Config{
|
||||
// AllowOrigins: []string{"http://192.168.7.160:8080/inquiry"},
|
||||
// AllowMethods: []string{"GET"},
|
||||
// AllowMethods: []string{"GET", "POST"},
|
||||
// AllowHeaders: []string{"Origin", "OCBO-ShieldConnection"},
|
||||
// ExposeHeaders: []string{"Content-Length"},
|
||||
// AllowCredentials: true,
|
||||
|
|
@ -71,7 +71,7 @@ func connect() {
|
|||
c.Writer.Header().Set("X-Frame-Options", "DENY")
|
||||
c.Writer.Header().Set("X-Download-Options", "noopen")
|
||||
c.Writer.Header().Set("Referrer-Policy", "no-referrer")
|
||||
c.Writer.Header().Set("Server", "Batman")
|
||||
c.Writer.Header().Set("Server", "OCBO Server")
|
||||
|
||||
switch method {
|
||||
case "test":
|
||||
|
|
@ -85,13 +85,14 @@ func connect() {
|
|||
case "check-connection":
|
||||
err = db.QueryRow("SELECT 1 AS result").Scan(&result)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
// c.AbortWithError(http.StatusBadRequest, err)
|
||||
// c.String(http.StatusBadRequest, err.Error())
|
||||
// c.String(http.StatusBadGateway, "false")
|
||||
c.JSON(http.StatusBadGateway, gin.H{"result": false})
|
||||
return
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"result": "Connection is OK",
|
||||
})
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"result": true})
|
||||
|
||||
case "get-listopapproval-electrical":
|
||||
var result2 string
|
||||
|
|
@ -642,6 +643,7 @@ func connect() {
|
|||
Data3 string `json:"data3"`
|
||||
Data4 string `json:"data4"`
|
||||
Data5 string `json:"data5"`
|
||||
Data6 int `json:"data6"`
|
||||
}
|
||||
var registrationData RegistrationData
|
||||
if err := c.ShouldBindJSON(®istrationData); err != nil {
|
||||
|
|
@ -657,13 +659,13 @@ func connect() {
|
|||
c.Writer.Header().Set("Referrer-Policy", "no-referrer")
|
||||
|
||||
dbpost, err := db.Prepare(`INSERT INTO electricaldocflowtxn (electricaldocflowtxnid, electricalid, txndate, remarks, comments, is_tag, tagword, is_approve, employeeid, is_delete)
|
||||
VALUES (NULL, ?, ?, NULL, ?, ?, 0, ?, 0)`)
|
||||
VALUES (NULL, ?, ?, ?, NULL, ?, ?, 0, ?, 0)`)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
defer dbpost.Close()
|
||||
|
||||
exec, err := dbpost.Exec(registrationData.Data, registrationData.Data2, registrationData.Data3, registrationData.Data4, registrationData.Data5)
|
||||
exec, err := dbpost.Exec(registrationData.Data, registrationData.Data2, registrationData.Data3, registrationData.Data4, registrationData.Data5, registrationData.Data6)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
|
@ -674,9 +676,9 @@ func connect() {
|
|||
}
|
||||
|
||||
if affect > 0 {
|
||||
c.String(http.StatusOK, "Success on Registrating e-Sign")
|
||||
c.String(http.StatusOK, "Success on Setting New Status")
|
||||
} else {
|
||||
c.String(http.StatusInternalServerError, "Failed on Registrating e-Sign")
|
||||
c.String(http.StatusInternalServerError, "Failed on Setting New Status")
|
||||
}
|
||||
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue