Opened 13 years ago
Closed 13 years ago
#699 closed enhancement (fixed)
add make-uri constructor to uri-generic and uri-common
Reported by: | Moritz Heidkamp | Owned by: | Ivan Raikov |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | extensions | Version: | 4.7.x |
Keywords: | Cc: | ||
Estimated difficulty: |
Description
Currently the only constructors for uri-generic and uri-common URI records are uri-reference
and absolute-uri
. This is slightly inconvenient when constructing a URI from individual components. For example, when starting Spiffy one might want to construct the URI it can be reached by. Currently one has to do something like this:
(update-uri (uri-reference "") scheme: (if (secure-connection?) 'https 'http) port: (server-port) host: (or (server-bind-address) "0.0.0.0"))
Whereas this would be much nicer:
(make-uri scheme: (if (secure-connection?) 'https 'http) port: (server-port) host: (or (server-bind-address) "0.0.0.0"))
It also seems more complete to have make-uri
in those eggs. Attached is a patch that implements it for both eggs in terms of update-uri
so as to touch as little code as possible. Feel free to apply it or re-implement it the other way around :-)
Attachments (1)
Change History (8)
Changed 13 years ago by
Attachment: | make-uri-for-uri-generic-and-uri-common.patch added |
---|
comment:1 Changed 13 years ago by
comment:2 follow-up: 3 Changed 13 years ago by
Indeed, but there is also an internal procedure update-URI
, yet the module exports a different function as update-uri
. I would prefer make-uri
for consistency with other record types. It's up to you though!
comment:3 Changed 13 years ago by
You are right, there is quite of bit of case mixup between internal and external procedures, so your patch would not make things worse. I have applied it to uri-generic and made a new release, 2.36.
Replying to syn:
Indeed, but there is also an internal procedure
update-URI
, yet the module exports a different function asupdate-uri
. I would prefermake-uri
for consistency with other record types. It's up to you though!
comment:4 Changed 13 years ago by
Milestone: | 4.8.0 |
---|
comment:5 Changed 13 years ago by
Hi Ivan,
thanks for applying the patch! What about the one for {{uri-common}} though? Do you object to its application or did you just overlook it?
comment:6 Changed 13 years ago by
I just ran into make-uri missing from uri-common again so I thought I'd check back on the issue :-)
comment:7 Changed 13 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Sorry about that, I had completely forgotten about it. I've added some tests to both uri-generic and uri-common for the constructor. This found a bug which I fixed (if you passed no path to the constructor, it failed). I've released uri-generic 2.37 and uri-common 1.3 so I'm closing this ticket.
If there's still something missing or wrong, please reopen the ticket or file a new one.
Thanks for the patch. The implementation of your make-uri seems ok, but there is an existing make-uri (actually make-URI) procedure, which is used internally. I would accept the patch if a different name was used. I suggest uri-from-parts but you are welcome to come up with a better suggestion.