@@ -40,6 +40,7 @@ API is subject to change until v1.0
40
40
* [ Custom port] ( #custom-port )
41
41
* [ Custom TLS config] ( #custom-tls-config )
42
42
* [ Testing] ( #testing )
43
+ * [ Titan protocol] ( #titan-protocol )
43
44
* [ Who uses Gig] ( #who-uses-gig )
44
45
* [ Benchmarks] ( #benchmarks )
45
46
* [ Contribute] ( #contribute )
@@ -530,6 +531,56 @@ func TestCertificate(t *testing.T) {
530
531
}
531
532
```
532
533
534
+ ### Titan Protocol
535
+
536
+ [ Titan] protocol is supported as middleware. Example titan server can be found
537
+ in ` examples/titan ` directory.
538
+
539
+ To use handle titan requests you must set ` AllowProxying ` property of gig to true.
540
+
541
+ ``` go
542
+ g := gig.Default ()
543
+ g.AllowProxying = true
544
+ ```
545
+
546
+ It is recommenced to set request read timeout to non zero value:
547
+
548
+ ``` go
549
+ g.ReadTimeout = time.Second * 10
550
+ ```
551
+
552
+ When creating middleware you must provide maximal request size in
553
+ bytes. Attempt to send bigger files than the limit will result in bad
554
+ request response.
555
+
556
+ ``` go
557
+ g.Use (gig.Titan (1024 ))
558
+ ```
559
+
560
+ Titan middleware detects requests using ` titan:// ` scheme and stores information about
561
+ it in request's context.
562
+
563
+ | key | type | description |
564
+ | -------| --------| -----------------------------------------|
565
+ | titan | bool | true if request is titan request |
566
+ | size | int | size of received file |
567
+ | mime | string | mime type as described in [ Titan] spec |
568
+ | token | string | auth token as described in [ Titan] spec |
569
+
570
+ The ` titan ` key in a context can be used to implement handlers that can
571
+ handle both titan and gemini requests.
572
+
573
+ Please note that if client sends less data than indicated by size parameter
574
+ then request should result in error response.
575
+
576
+ There are two utility function provided to make writing Titan servers easier:
577
+
578
+ - ` TitanReadFull ` : reads whole request into a buffer. Takes care of case
579
+ when client sends less data than expeted.
580
+ - ` TitanRedirect ` : redirects client to the gemini resource uploaded in the request.
581
+
582
+ [ Titan ] : https://communitywiki.org/wiki/Titan
583
+
533
584
## Who uses Gig
534
585
535
586
Gig is used by the following capsules:
0 commit comments