summaryrefslogtreecommitdiff
path: root/plugins/http/plugin.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-12-03 13:08:38 +0300
committerValery Piashchynski <[email protected]>2020-12-03 13:08:38 +0300
commit31e4bb7b236fe0ae59fd42d66af0d718b67a2a4b (patch)
treecd51f81b20dc32666165ff85d8b8bdad0e6c464c /plugins/http/plugin.go
parentbdabf97a6463c0e3897063235f3d556d4f75c4bd (diff)
Initial commit of checker plugin
Diffstat (limited to 'plugins/http/plugin.go')
-rw-r--r--plugins/http/plugin.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/plugins/http/plugin.go b/plugins/http/plugin.go
index 79e8aa94..371cdb91 100644
--- a/plugins/http/plugin.go
+++ b/plugins/http/plugin.go
@@ -18,6 +18,7 @@ import (
"github.com/spiral/roadrunner/v2"
"github.com/spiral/roadrunner/v2/interfaces/log"
factory "github.com/spiral/roadrunner/v2/interfaces/server"
+ "github.com/spiral/roadrunner/v2/interfaces/status"
"github.com/spiral/roadrunner/v2/plugins/config"
"github.com/spiral/roadrunner/v2/plugins/http/attributes"
"github.com/spiral/roadrunner/v2/util"
@@ -341,6 +342,22 @@ func (s *Plugin) AddMiddleware(name endure.Named, m Middleware) {
s.mdwr[name.Name()] = m
}
+// Status return status of the particular plugin
+func (s *Plugin) Status() status.Status {
+ workers := s.Workers()
+ for i := 0; i < len(workers); i++ {
+ if workers[i].State().IsActive() {
+ return status.Status{
+ Code: http.StatusOK,
+ }
+ }
+ }
+ // if there are no workers, threat this as error
+ return status.Status{
+ Code: http.StatusInternalServerError,
+ }
+}
+
func (s *Plugin) redirect(w http.ResponseWriter, r *http.Request) bool {
if s.https != nil && r.TLS == nil && s.cfg.SSL.Redirect {
target := &url.URL{