RangerMauve / hypercore-fetch

Implementation of Fetch that uses the Hyper SDK for loading p2p content
MIT License
37 stars 13 forks source link

Replace Non-standard methods with special paths #23

Closed RangerMauve closed 2 years ago

RangerMauve commented 3 years ago

After playing with this for a while, it seems that using non-standard method names is a huge issue with clients.

For example, Godot only supports GET, HEAD, POST, PUT, DELETE, OPTIONS, TRACE, CONNECT, and PATCH

Node has a bunch more methods, but we're using a bunch that aren't supported there either.

I propose instead using a special path for things that aren't just Hyperdrive data. Maybe under the prefix like hyper://example/$/ or hyper://example/@

Here's the weird method names we'll need to fill and some proposals:

DOWNLOAD hyper://example/path/to/thing => GET hyper://example/path/to/thing?seed CLEAR hyper://example/path/to/thing => DELETE hyper://example/path/to/thing?clear TAG hyper://example/ TAG_NAME => PUT hyper://example/$/tags/TAG_NAME TAGS hyper://example/ => GET hyper://example/$/tags/ TAG-DELETE hyper://example/ => DELETE hyper://examples/$tags/TAG_NAME

This could also play well with the need to expose additional data like peers and extensions. e.g GET hyper://example/$/peers/

Does this seem like a good idea? Any suggestions for the path names?

RangerMauve commented 3 years ago

Some options for special path formats:

  1. hyper://example/$/tags/
  2. hyper://example/$tags/
  3. hyper://example/@/tags/
  4. hyper://example/@tags/

Note, we need characters that might not be valid FS paths, but won't conflict with URL things like ? and #

RangerMauve commented 3 years ago

Gonna go with /$/ for now.

RangerMauve commented 3 years ago

This is out in 8.0.0-0. Going to test it a bit before doing a full release, but that's likely what it's going to end up looking like.

RangerMauve commented 2 years ago

This has been released for a while actually. 😅