Skip to content

Commit

Permalink
add titan documentation to README
Browse files Browse the repository at this point in the history
  • Loading branch information
TeddyDD committed Jul 9, 2022
1 parent 13f2226 commit f55bd19
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ API is subject to change until v1.0
* [Custom port](#custom-port)
* [Custom TLS config](#custom-tls-config)
* [Testing](#testing)
* [Titan protocol](#titan-protocol)
* [Who uses Gig](#who-uses-gig)
* [Benchmarks](#benchmarks)
* [Contribute](#contribute)
Expand Down Expand Up @@ -530,6 +531,56 @@ func TestCertificate(t *testing.T) {
}
```

### Titan Protocol

[Titan] protocol is support as middleware. Example titan server can be found
in `examples/titan` directory.

To use handle titan requests you must set `AllowProxying` property of gig to true.

```go
g := gig.Default()
g.AllowProxying = true
```

It is recommenced to set request read timeout to non zero value:

```go
g.ReadTimeout = time.Second * 10
```

When creating middleware you must provide maximal request size in
bytes. Attempt to send bigger files than the limit will result in bad
request response.

```go
g.Use(gig.Titan(1024))
```

Titan middleware detects requests using `titan://` scheme and stores information about
it in request's context.

| key | type | description |
|-------|--------|-----------------------------------------|
| titan | bool | true if request is titan request |
| size | int | size of received file |
| mime | string | mime type as described in [Titan] spec |
| token | string | auth token as described in [Titan] spec |

The `titan` key in a context can be used to implement handlers that can
handle both titan and gemini requests.

Please note that if client sends less data than indicated by size parameter
then request should result in error response.

There are two utility function provided to make writing Titan servers easier:

- `TitanReadFull`: reads whole request into a buffer. Takes care of case
when client sends less data than expeted.
- `TitanRedirect`: redirects client to the gemini resource uploaded in the request.

[Titan]: https://communitywiki.org/wiki/Titan

## Who uses Gig

Gig is used by the following capsules:
Expand Down

0 comments on commit f55bd19

Please sign in to comment.