forked from
tangled.org/core
fork
Configure Feed
Select the types of activity you want to include in your feed.
this repo has no description
fork
Configure Feed
Select the types of activity you want to include in your feed.
1package knotserver
2
3import (
4 "net/http"
5 "os"
6 "path/filepath"
7
8 "github.com/bluesky-social/indigo/atproto/syntax"
9 securejoin "github.com/cyphar/filepath-securejoin"
10 "github.com/go-chi/chi/v5"
11)
12
13func didPath(r *http.Request) string {
14 did := chi.URLParam(r, "did")
15 name := chi.URLParam(r, "name")
16 path, _ := securejoin.SecureJoin(did, name)
17 filepath.Clean(path)
18 return path
19}
20
21func getDescription(path string) (desc string) {
22 db, err := os.ReadFile(filepath.Join(path, "description"))
23 if err == nil {
24 desc = string(db)
25 } else {
26 desc = ""
27 }
28 return
29}
30func setContentDisposition(w http.ResponseWriter, name string) {
31 h := "inline; filename=\"" + name + "\""
32 w.Header().Add("Content-Disposition", h)
33}
34
35func setGZipMIME(w http.ResponseWriter) {
36 setMIME(w, "application/gzip")
37}
38
39func setMIME(w http.ResponseWriter, mime string) {
40 w.Header().Add("Content-Type", mime)
41}
42
43var TIDClock = syntax.NewTIDClock(0)
44
45func TID() string {
46 return TIDClock.Next().String()
47}