Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Auto = types.Middleware(func(h types.Handler) types.Handler { return types.HandlerFunc(func(ctx context.Context, request *types.Request) *types.Response { if !(request.Scheme == "gemini" || request.Scheme == "spartan") || !strings.HasSuffix(request.Path, ".atom") { return h.Handle(ctx, request) } r := *request u := *request.URL u.Path = u.Path[:len(u.Path)-5] r.URL = &u response := h.Handle(ctx, &r) var ( success sliderule.Status buildSuccess func(string, io.Reader) *sliderule.Response buildFailure func(error) *sliderule.Response ) switch request.Scheme { case "gemini": success = gemini.StatusSuccess buildSuccess = gemini.Success buildFailure = gemini.Failure case "spartan": success = spartan.StatusSuccess buildSuccess = spartan.Success buildFailure = spartan.ServerError } if response.Status != success { return response } mtype, _, err := mime.ParseMediaType(response.Meta.(string)) if err != nil || mtype != "text/gemini" { return response } defer func() { _ = response.Close() }() doc, err := gemtext.Parse(response.Body) if err != nil { return buildFailure(err) } buf := &bytes.Buffer{} if err := Convert(buf, doc, request.URL); err != nil { return buildFailure(err) } return buildSuccess("application/atom+xml; charset=utf-8", buf) }) })
Auto is a middleware which builds atom feeds for any gemtext pages.
It looks for requests ending with the '.atom' extension, passes through the request with the extension clipped off, then if the response is in gemtext it converts it to an Atom feed according to the gmisub spec at gemini://gemini.circumlunar.space/docs/companion/subscription.gmi
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.