Search code examples
spark-java

Route/url lookup from template? (Java Spark framework)


Is there a way for spark-java to do reverse url lookups of routes from the template?

Like Python Django, for example:

Returns an absolute path reference (a URL without the domain name) matching a given view and optional parameters. Any special characters in the resulting path will be encoded using iri_to_uri().

This is a way to output links without violating the DRY principle by having to hard-code URLs in your templates:

{% url 'some-url-name' v1 v2 %}

I have not seen an option in the Spark docs that talks about named routes … If this feature is not available (guessing not) how hard do you think it be to incorporate into the core framework? Where do we submit feature requests?

Thanks!


Solution

  • It is hard to estimate how hard it would be to add your wanted feature. I would suggest that you add it and then evaluate how long time it took.

    Feature requests can be registered as issues at https://github.com/perwendel/spark

    As Spark-java is open source and maintained by volunteers, it would probably be a better idea to submit a pull request where you have added the functionality you want.