File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,21 @@ func (s *BaseHttpGateway) api(ctx *fasthttp.RequestCtx) {
54
54
apiName := ctx .UserValue ("name" ).(string )
55
55
// Rewrite the URL of the request to remove the /api/{name} subroute
56
56
pathParts := nitric_utils .SplitPath (string (ctx .Path ()))
57
+
58
+ // When a request is made to the base API path, return status info
59
+ if len (pathParts ) == 2 {
60
+ w := s .pool .GetWorkers (& worker.GetWorkerOptions {
61
+ Filter : apiWorkerFilter (apiName ),
62
+ })
63
+ ctx .Response .SetBody ([]byte (fmt .Sprintf ("<html><body><strong>%d</strong> active route(s) detected for API %v.</body></html>" , len (w ), apiName )))
64
+ if len (w ) > 0 {
65
+ ctx .Response .SetStatusCode (200 )
66
+ } else {
67
+ ctx .Response .SetStatusCode (404 )
68
+ }
69
+ return
70
+ }
71
+
57
72
// remove first two path parts
58
73
newPathParts := pathParts [2 :]
59
74
@@ -124,9 +139,9 @@ func (s *BaseHttpGateway) Start(pool worker.WorkerPool) error {
124
139
125
140
// Setup routes
126
141
r := router .New ()
127
- // Make a request for an API gateway
128
- r .ANY ("/apis/{name}/{any:*}" , s .api )
129
- // trigger a topic
142
+ // Make a request to an API gateway
143
+ r .ANY ("/apis/{name}/{any? :*}" , s .api )
144
+ // Publish to a topic
130
145
r .POST ("/topic/{name}" , s .topic )
131
146
132
147
s .server = & fasthttp.Server {
You can’t perform that action at this time.
0 commit comments