Updated backend
This commit is contained in:
parent
8e9b6048dd
commit
0dfa74b76f
1 changed files with 48 additions and 3 deletions
|
|
@ -32,7 +32,8 @@ func getCORSConfig(env string) cors.Config {
|
|||
return cors.Config{
|
||||
AllowOrigins: []string{"http://localhost:5173"},
|
||||
AllowMethods: []string{"GET", "POST", "OPTIONS", "DELETE"},
|
||||
AllowHeaders: []string{"Origin", "OCBO-Token", "Content-Length", "Content-Type", "X-Server"},
|
||||
// AllowHeaders: []string{"Origin", "OCBO-Token", "Content-Length", "Content-Type", "X-Server", "Authorization"},
|
||||
AllowHeaders: []string{"*"},
|
||||
ExposeHeaders: []string{"Content-Length"},
|
||||
AllowCredentials: true,
|
||||
}
|
||||
|
|
@ -2492,5 +2493,49 @@ func connect() {
|
|||
}
|
||||
})
|
||||
|
||||
router.DELETE("/api/delete-esigntransactions", func(c *gin.Context) {
|
||||
type DeleteOPLocal struct {
|
||||
Data string `json:"data"`
|
||||
}
|
||||
var deleteOpLocal DeleteOPLocal
|
||||
if err := c.ShouldBindJSON(&deleteOpLocal); err != nil {
|
||||
c.String(http.StatusBadRequest, "Invalid request body")
|
||||
return
|
||||
}
|
||||
|
||||
c.Writer.Header().Set("X-XSS-Protection", "1; mode=block")
|
||||
c.Writer.Header().Set("X-Content-Type-Options", "nosniff")
|
||||
c.Writer.Header().Set("X-DNS-Prefetch-Control", "off")
|
||||
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("Content-Security-Policy", "default-src 'self'; img-src 'self';")
|
||||
c.Writer.Header().Set("X-Server", "OCBO Server")
|
||||
|
||||
dbpost, err := dbpop.Prepare("DELETE FROM esign_transactions WHERE referenceNo = ?")
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
c.String(http.StatusInternalServerError, "Internal Server Error")
|
||||
return
|
||||
}
|
||||
defer dbpost.Close()
|
||||
|
||||
exec, err := dbpost.Exec(deleteOpLocal.Data)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
affect, err := exec.RowsAffected()
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
if affect > 0 {
|
||||
c.String(http.StatusOK, "Success on Deleting eSign Transactions")
|
||||
} else {
|
||||
c.String(http.StatusInternalServerError, "Failed on Deleting eSign Transactions")
|
||||
}
|
||||
})
|
||||
|
||||
router.Run(":4320")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue