adding lifecycle hook for test exit

This commit is contained in:
josebarn
2017-08-16 09:08:13 -03:00
parent c9978db11a
commit 78d1b044e9
3 changed files with 38 additions and 7 deletions

26
api/lifecycle.go Normal file
View File

@@ -0,0 +1,26 @@
package api
import (
"github.com/go-chi/chi"
"github.com/go-chi/render"
"net/http"
"os"
)
type AppLifecycleResource struct{}
// Routes creates a REST router for the todos resource
func (self AppLifecycleResource) Routes() chi.Router {
r := chi.NewRouter()
r.Route("/lifecycle", func(r chi.Router) {
r.Post("/stop", self.stop)
})
return r
}
func (self AppLifecycleResource) stop(w http.ResponseWriter, r *http.Request) {
render.Status(r, http.StatusOK)
os.Exit(0)
}