Sub Class_Globals
Private Request As ServletRequest
Private Response As ServletResponse
End Sub
Public Sub Initialize
End Sub
Sub Handle (req As ServletRequest, resp As ServletResponse)
Request = req
Response = resp
ProcessRequest
End Sub
Private Sub ProcessRequest
Log($"[${Request.Method}] ${Request.RequestURI}"$)
If EndsMeetUtils.isWebRequest(Request.RequestURI, Main.BaseElements) = False Then
Response.SendError(400, "Bad Request")
Return
End If
Dim RequestMap As Map = EndsMeetUtils.GetRequestElements(Request.RequestURI, Main.BaseElements)
Dim Path As String = RequestMap.Get("Path")
If Path.EqualsIgnoreCase(Main.BaseElements.Path.Element) = False Then
Response.SendError(400, "Bad Request")
Return
End If
Select RequestMap.Size
Case 1 ' root
Log(RequestMap)
Case 2 ' path (demo)
Dim Index As IndexView
Index.Initialize(Request, Response)
Index.Render
Return
Case Else
Dim Controller As String = RequestMap.Get("Controller")
Select Controller
Case "hello"
Dim Hello As HelloController
Hello.Initialize(Request, Response)
Hello.RouteWeb
Return
Case "messages"
DateTime.DateFormat = "dd/MM/yyyy HH:mm:ssa"
Response.Write(DateTime.Date(DateTime.Now))
Return
Case "trigger_delay"
Dim q As String = Request.GetParameter("q")
If q = "" Then
Response.Write("No result")
Else
Response.Write(q)
End If
Return
End Select
End Select
Response.SendError(400, "Bad Request")
End Sub