pitr / gig

Gemini framework
MIT License
61 stars 5 forks source link

Basic Titan Support #8

Open ghost opened 3 years ago

ghost commented 3 years ago

It'd be cool to have basic Titan support. Titan is a complementary protocol to gemini that allows for upload only.

It uses the same port as gemini, but URLs use the "titan://" scheme. The URLs consist of a path with parameters delimited by semicolons (;), with 3 different parameters, an optional token (kinda like a password, not used for authorization, but rather to prevent bots and spam), a requied size (in bytes) of file to be uploaded, and a required mime parameter (mimetype). After that, then there's a \r\n, followed by the data of the given size.

It also supports Client Certificates.

If the given data is of the wrong size, "59 Meta text" is sent. Otherwise, nothing is sent back, afaik (I could be wrong about this).

Here's the main page for the protocol: https://communitywiki.org/wiki/Titan You can see a server implementation here: https://alexschroeder.ch/cgit/phoebe/tree/script/phoebe And for the client: https://alexschroeder.ch/cgit/phoebe/tree/script/titan

Even just some way to hook into Gig to just get all requests that use the titan:// scheme and do my own stuff would be useful. But, if it used some of Gig's features, like routes, that would be cool too :)

pitr commented 3 years ago

Thanks for the idea. I haven't used Titan myself, though familiar with it. My initial thought would be to add to gig.Context something is IsTitan() bool and IsGemini() bool for handler to be able to distinguish the two. And perhaps a setting on gig.Gig (off by default) to enable Titan support. What do you think? Would love it if a PR was contributed to support it.

ghost commented 3 years ago

Yeah, that could work. I'll see if I can make a PR either today or tomorrow. Thanks!