[Improvement] unify endpoint URL format
Feature Description
Background
Currently, restserver.url and some other(such as gremlinserver.url, and others in ServerOptions.java) in rest-server.properties requires an explicit scheme prefix such as http://, which can be slightly inconvenient and inconsistent with other modules.
In some components (e.g. Graph AI), URLs without a scheme are supported by defaulting to http, while allowing users to override the scheme explicitly. This provides a more user-friendly configuration experience.
Current Behavior
restserver.url property must include a full scheme, for example:
restserver.url=http://127.0.0.1:8080
If the scheme is omitted, the URL may fail to be parsed or behave unexpectedly.
Expected Behavior
Support a unified and more flexible configuration rule for restserver.url:
Scheme is optional
If no scheme is provided, default to http://
restserver.url=127.0.0.1:8080
Explicit scheme should override the default
restserver.url=http://127.0.0.1:8080 restserver.url=https://127.0.0.1:8080
Proposed Change
During configuration parsing:
If restserver.url does not contain a scheme (e.g. http://, https://), automatically prepend http://
If a scheme is present, preserve the original value
One corner case to watch out for: not all URL options should default to http://.
For example server.k8s_url currently defaults to https://127.0.0.1:8888 and in real deployments K8S API often requires HTTPS + CA config. If we implement a generic “prepend http:// when scheme is missing” for all URL-like keys (anything containing url / urls), then a user config like:
server.k8s_url=127.0.0.1:8888
would silently become http://127.0.0.1:8888, effectively downgrading the scheme and potentially breaking K8S integration.
https://github.com/apache/incubator-hugegraph/blob/37be6cdde3a2ffb71091453b366f28ae446db882/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/config/ServerOptions.java#L275-L282
One corner case to watch out for: not all URL options should default to http://.
For example server.k8s_url currently defaults to 127.0.0.1:8888 and in real deployments K8S API often requires HTTPS + CA config. If we implement a generic “prepend http:// when scheme is missing” for all URL-like keys (anything containing url / urls), then a user config like:
server.k8s_url=127.0.0.1:8888
would silently become http://127.0.0.1:8888, effectively downgrading the scheme and potentially breaking K8S integration.
Lines 275 to 282 in 37be6cd
public static final ConfigOption
SERVER_K8S_URL = new ConfigOption<>( "server.k8s_url", "The url of k8s.", disallowEmpty(), "https://127.0.0.1:8888" );
@bitflicker64 Good catch, thank you for your reminder and careful consideration. Your perspective is very reasonable, and our intention is not to enforce a uniform prefix for all configurations.
The core point is that for configurations that do not affect the outcome and are suitable for using the default http:// prefix, we should maintain consistency and ease of use. For specific configurations that are not suitable for using http:// (such as server.k8s_url), we should allow separate configuration to override the default value. We will provide unified encapsulation at the code level while allowing flexible selection at the configuration level based on actual circumstances. Thank you again for your valuable feedback!