Skip to content

Commit dadcd0a

Browse files
committed
Add crash endpoint
1 parent e86fb53 commit dadcd0a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

pkg/handler/handler.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package handler
33
import (
44
"github.com/gin-gonic/gin"
55
"github.com/thecasualcoder/dobby/pkg/config"
6+
"log"
67
"os"
78
"strconv"
89
)
@@ -24,6 +25,11 @@ func Version(c *gin.Context) {
2425
c.JSON(200, gin.H{"version": version})
2526
}
2627

28+
// Crash will make dobby to kill itself
29+
func Crash(_ *gin.Context) {
30+
log.Fatal("you asked me do so, killing myself :-)")
31+
}
32+
2733
func init() {
2834
healthy, err := strconv.ParseBool(os.Getenv("HEALTH"))
2935

pkg/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ func Run(bindAddress, port string) error {
1212

1313
r.GET("/health", handler.Health)
1414
r.GET("/version", handler.Version)
15+
r.PUT("/state/crash", handler.Crash)
1516
return r.Run(fmt.Sprintf("%s:%s", bindAddress, port))
1617
}

0 commit comments

Comments
 (0)