I want to use sparkjava, to make a imageAPI, that returns a image with text, that was provided through the link itself.
f.e. I would do http://localhost:4567/?text=some%20text and it would return a image, that has the text "some text" in it.
But in my case will there be multiple params like who requested it, the color, the image, etc.
How can I let sparkjava listen to for example http://localhost:4567/img?text=some%20text&user=user but also for http://localhost:4567/img?user=user&text=some%20text
Would I have to set a get for every possible way, or is there a option, to let it listen for the params and ignore the order?
Like would the following code only work for http://localhost:4567/img?text=some%20text&user=user or would it also work for other the other example?
public void main(String[] args){
get("/img?text=:text&user=:user", (req, res) -> {
String text = req.params(":text");
String user = req.params(":user");
// We would return the image directly for that link
return ImageUtil.newImage(text, user);
});
}
I assume that this would only work for the provided format in the link (text first, then user) and not for the other one too.
I want to use sparkjava, to make a imageAPI, that returns a image with text, that was provided through the link itself. f.e. I would do
http://localhost:4567/?text=some%20text
and it would return a image, that has the text "some text" in it. But in my case will there be multiple params like who requested it, the color, the image, etc.How can I let sparkjava listen to for example
http://localhost:4567/img?text=some%20text&user=user
but also forhttp://localhost:4567/img?user=user&text=some%20text
Would I have to set a
get
for every possible way, or is there a option, to let it listen for the params and ignore the order?Like would the following code only work for
http://localhost:4567/img?text=some%20text&user=user
or would it also work for other the other example?I assume that this would only work for the provided format in the link (text first, then user) and not for the other one too.