summaryrefslogtreecommitdiff
path: root/plugins/http/plugin.go
diff options
context:
space:
mode:
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{