B4J Code Snippet Spark Framework POC

Hi! so i was chatting with @ilan about the idea of having multiple entries on the url parameters.

Due my experience, i know this is not possible, until later in the day i found in some documentation on Stripe that Spark (jetty based) actually allows to do this.

So I decided to test it and vuala! it worked!

Called: http://localhost:4000/hello/ilan/age/25
Code: Log($"hello ${name}, age ${age}"$)
Logged: hello ilan, age 25

Of course this is just a proof of concept, i actually can return only "world" (lol 😅) to the browser

if you want to run a spin download the jar from here:
as it will get you all the dependencies.

this was just to demonstrate that for some reason Jetty doesnt allow parameters, but spark that is built on top of it allows. may be we are just missing something? only time will tell.

'Non-UI application (console / server application)
#Region Project Attributes 
    #MergeLibraries: True 
    #AdditionalJar: spark-core-2.9.3.jar
    #AdditionalJar: slf4j-api-1.7.30.jar
    #AdditionalJar: javax.servlet-api-3.1.0.jar
    #AdditionalJar: jetty-server-9.4.31.v20200723.jar
    #AdditionalJar: jetty-util-9.4.31.v20200723.jar
    #AdditionalJar: jetty-http-9.4.31.v20200723.jar
    #AdditionalJar: jetty-io-9.4.31.v20200723.jar
#End Region

Sub Process_Globals
End Sub

Sub AppStart (Args() As String)
    Dim sp As JavaObject
    Dim event As Object = (Me).As(JavaObject).CreateEvent("spark.Route","getter","world")
End Sub

public Sub getter_Event (MethodName As String, Args() As Object) As Object
    Dim req As JavaObject = Args(0)
    Dim name As String = req.RunMethod("params",Array(":name"))
    Dim age As String = req.RunMethod("params",Array(":age"))
    Log($"hello ${name}, age ${age}"$)
    Return ""
End Sub
Last edited: