Sub Handle(req As ServletRequest, resp As ServletResponse)
resp.ContentType = "application/json"
Dim Response As String
Select Case req.Method
Case "GET"
If req.RequestURI.Length + 1 <= "/v1/admin/monitor/".Length Then
ABMShared.SendError(resp, 404, "Invalid call")
Return
End If
Dim PostType As String = req.RequestURI.SubString("/v1/admin/monitor/".Length)
Select Case PostType
Case "latest"
RunAPI(resp) '<---- calling the Rest API
StartMessageLoop
Case Else
ABMShared.SendError(resp, 404, "Invalid call")
Return
End Select
Case "POST" ' Update a scanner assignment
...
Sub RunAPI(resp As ServletResponse)
Dim j As HttpJob
j.Initialize("", Me)
j.Download(Main.MonitorUrl & "/monitor/latest")
j.GetRequest.SetHeader("api_key", "eyJhbGciOiJIUzUxMiIsInppc......")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
'Log("Success")
Dim body As TextReader
body.Initialize(j.GetInputStream)
resp.Write(body.ReadAll)
Else
resp.Status = j.Response.StatusCode
resp.Write(j.Response.ErrorResponse)
End If
j.Release
StopMessageLoop
End Sub