How can you configure context path using com.sparkjava:spark-core
with jetty?
EDIT:
Instead of root app context being http://mydomain.xyz
the app would be accessed through http://mydomain.xyz/custom-context
.
How can you configure context path using com.sparkjava:spark-core
with jetty?
EDIT:
Instead of root app context being http://mydomain.xyz
the app would be accessed through http://mydomain.xyz/custom-context
.
Copyright © 2021 Jogjafile Inc.
spark-java does not directly support setting the context as a separate setting, but it still can be done. Probably the easiest way is to use the Path groups as outlined in the docs.
Example from the documentation:
So, by putting all route definitions within a
path
-call, you can easily set a context-like base-route for all your URLs. Theoretically, you could load this base-path (or context) from a configuration file, then it would be: