The code and data behind xeiaso.net
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

add an external API

Signed-off-by: Xe Iaso <me@xeiaso.net>

Xe Iaso 8d63fd1b 5a4d6d92

+340 -96
+2 -20
cmd/patreon-saasproxy/main.go
··· 3 3 import ( 4 4 "context" 5 5 "encoding/base64" 6 - "encoding/json" 7 6 "flag" 8 7 "log" 9 8 "log/slog" ··· 14 13 15 14 "github.com/facebookgo/flagenv" 16 15 _ "github.com/joho/godotenv/autoload" 16 + "github.com/twitchtv/twirp" 17 17 "golang.org/x/oauth2" 18 18 "google.golang.org/protobuf/types/known/emptypb" 19 19 "google.golang.org/protobuf/types/known/timestamppb" ··· 80 80 cts: cts, 81 81 } 82 82 83 - http.HandleFunc("/give-token", s.GiveToken) 84 - 85 83 ph := adminpb.NewPatreonServer(s) 86 84 http.Handle(adminpb.PatreonPathPrefix, ph) 87 85 ··· 104 102 token, err := s.cts.Token() 105 103 if err != nil { 106 104 slog.Error("token fetch failed", "err", err) 107 - return nil, err 105 + return nil, twirp.InternalErrorWith(err) 108 106 } 109 107 110 108 return &adminpb.PatreonToken{ ··· 114 112 Expiry: timestamppb.New(token.Expiry), 115 113 }, nil 116 114 } 117 - 118 - func (s *Server) GiveToken(w http.ResponseWriter, r *http.Request) { 119 - token, err := s.cts.Token() 120 - if err != nil { 121 - slog.Error("token fetch failed", "err", err) 122 - http.Error(w, "token fetch failed", http.StatusInternalServerError) 123 - return 124 - } 125 - 126 - w.Header().Set("Content-Type", "application/json") 127 - 128 - if err := json.NewEncoder(w).Encode(token); err != nil { 129 - slog.Error("token encode failed", "err", err) 130 - return 131 - } 132 - }
+44
cmd/xesite/api.go
··· 1 + package main 2 + 3 + import ( 4 + "context" 5 + "os" 6 + "os/exec" 7 + "runtime" 8 + 9 + "github.com/twitchtv/twirp" 10 + "google.golang.org/protobuf/types/known/emptypb" 11 + "google.golang.org/protobuf/types/known/timestamppb" 12 + "xeiaso.net/v4/internal/lume" 13 + "xeiaso.net/v4/pb" 14 + ) 15 + 16 + type MetaServer struct { 17 + fs *lume.FS 18 + } 19 + 20 + func (ms *MetaServer) Metadata(ctx context.Context, _ *emptypb.Empty) (*pb.BuildInfo, error) { 21 + deno, err := exec.LookPath("deno") 22 + if err != nil { 23 + return nil, twirp.InternalErrorf("can't find deno in $PATH: %w", err) 24 + } 25 + 26 + commit, err := ms.fs.Commit() 27 + if err != nil { 28 + return nil, twirp.InternalErrorf("can't get commit hash: %w", err) 29 + } 30 + 31 + result := &pb.BuildInfo{ 32 + Commit: commit, 33 + GoVersion: runtime.Version(), 34 + DenoVersion: deno, 35 + XesiteVersion: os.Args[0], 36 + BuildTime: timestamppb.New(ms.fs.BuildTime()), 37 + } 38 + 39 + if *devel { 40 + result.XesiteVersion = "devel" 41 + } 42 + 43 + return result, nil 44 + }
+35
cmd/xesite/internalapi.go
··· 6 6 "log" 7 7 "net" 8 8 "net/http" 9 + "os" 10 + "os/exec" 9 11 "path/filepath" 12 + "runtime" 10 13 14 + "github.com/twitchtv/twirp" 15 + "google.golang.org/protobuf/types/known/emptypb" 16 + "google.golang.org/protobuf/types/known/timestamppb" 17 + "xeiaso.net/v4/internal/adminpb" 11 18 "xeiaso.net/v4/internal/lume" 19 + "xeiaso.net/v4/pb" 12 20 ) 13 21 14 22 func internalAPI(fs *lume.FS) { ··· 26 34 http.ServeFile(w, r, filepath.Join(*dataDir, "site.zip")) 27 35 }) 28 36 37 + mux.Handle(adminpb.AdminPathPrefix, adminpb.NewAdminServer(&AdminAPI{fs: fs})) 38 + 29 39 ln, err := net.Listen("tcp", ":80") 30 40 if err != nil { 31 41 log.Fatal(err) ··· 33 43 34 44 http.Serve(ln, mux) 35 45 } 46 + 47 + type AdminAPI struct { 48 + fs *lume.FS 49 + } 50 + 51 + func (aa *AdminAPI) Rebuild(ctx context.Context, _ *emptypb.Empty) (*pb.BuildInfo, error) { 52 + deno, err := exec.LookPath("deno") 53 + if err != nil { 54 + return nil, twirp.InternalErrorf("can't find deno in $PATH: %w", err) 55 + } 56 + 57 + result := &pb.BuildInfo{ 58 + GoVersion: runtime.Version(), 59 + DenoVersion: deno, 60 + XesiteVersion: os.Args[0], 61 + } 62 + 63 + if err := aa.fs.Update(ctx); err != nil { 64 + return nil, twirp.InternalErrorWith(err) 65 + } 66 + 67 + result.BuildTime = timestamppb.Now() 68 + 69 + return result, nil 70 + }
+6
cmd/xesite/main.go
··· 13 13 "github.com/donatj/hmacsig" 14 14 "github.com/facebookgo/flagenv" 15 15 _ "github.com/joho/godotenv/autoload" 16 + "github.com/twitchtv/twirp" 16 17 "xeiaso.net/v4/internal" 17 18 "xeiaso.net/v4/internal/lume" 19 + "xeiaso.net/v4/pb" 18 20 ) 19 21 20 22 var ( ··· 77 79 78 80 mux := http.NewServeMux() 79 81 mux.Handle("/", http.FileServer(http.FS(fs))) 82 + mux.Handle("/api/defs/", http.StripPrefix("/api/defs/", http.FileServer(http.FS(pb.Proto)))) 83 + 84 + ms := pb.NewMetaServer(&MetaServer{fs}, twirp.WithServerPathPrefix("/api")) 85 + mux.Handle(ms.PathPrefix(), ms) 80 86 81 87 mux.HandleFunc("/blog.atom", func(w http.ResponseWriter, r *http.Request) { 82 88 http.Redirect(w, r, "/blog.rss", http.StatusMovedPermanently)
+11
go.mod
··· 24 24 dario.cat/mergo v1.0.0 // indirect 25 25 github.com/Microsoft/go-winio v0.6.1 // indirect 26 26 github.com/ProtonMail/go-crypto v1.0.0 // indirect 27 + github.com/blockthrough/twirp-openapi-gen v0.0.0-20231107141308-45a52eb7d856 // indirect 27 28 github.com/cloudflare/circl v1.3.7 // indirect 28 29 github.com/cyphar/filepath-securejoin v0.2.4 // indirect 30 + github.com/emicklei/proto v1.11.2 // indirect 29 31 github.com/emirpasic/gods v1.18.1 // indirect 30 32 github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c // indirect 31 33 github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 // indirect 34 + github.com/getkin/kin-openapi v0.120.0 // indirect 32 35 github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect 33 36 github.com/go-git/go-billy/v5 v5.5.0 // indirect 37 + github.com/go-openapi/jsonpointer v0.20.0 // indirect 38 + github.com/go-openapi/swag v0.22.4 // indirect 34 39 github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect 35 40 github.com/golang/protobuf v1.5.3 // indirect 41 + github.com/invopop/yaml v0.2.0 // indirect 36 42 github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect 43 + github.com/josharian/intern v1.0.0 // indirect 37 44 github.com/kevinburke/ssh_config v1.2.0 // indirect 45 + github.com/mailru/easyjson v0.7.7 // indirect 46 + github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect 47 + github.com/perimeterx/marshmallow v1.1.5 // indirect 38 48 github.com/pjbgf/sha1cd v0.3.0 // indirect 39 49 github.com/sergi/go-diff v1.3.1 // indirect 40 50 github.com/skeema/knownhosts v1.2.1 // indirect ··· 48 58 golang.org/x/tools v0.17.0 // indirect 49 59 google.golang.org/appengine v1.6.8 // indirect 50 60 gopkg.in/warnings.v0 v0.1.2 // indirect 61 + gopkg.in/yaml.v3 v3.0.1 // indirect 51 62 )
+21
go.sum
··· 11 11 github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= 12 12 github.com/bep/debounce v1.2.1 h1:v67fRdBA9UQu2NhLFXrSg0Brw7CexQekrBwDMM8bzeY= 13 13 github.com/bep/debounce v1.2.1/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0= 14 + github.com/blockthrough/twirp-openapi-gen v0.0.0-20231107141308-45a52eb7d856 h1:7m7Q6EErVZWPIp1UeVSb5zUTFzV6m7ZUcUIpbWffBfs= 15 + github.com/blockthrough/twirp-openapi-gen v0.0.0-20231107141308-45a52eb7d856/go.mod h1:UN1OFH6gXrM9qKvXPcs4dOAAMB1tC4kw/eUzdA/bmI8= 14 16 github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= 15 17 github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= 16 18 github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= ··· 24 26 github.com/donatj/hmacsig v1.1.0/go.mod h1:rh/7q72Fo5oYc7bcKgvGHWsfHcs8jKhJdFgCZcvZ/G0= 25 27 github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU= 26 28 github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= 29 + github.com/emicklei/proto v1.11.2 h1:DiIeyTJ+gPSyJI+RIAqvuTeKb0tLUmaGXbYg6aFKsnE= 30 + github.com/emicklei/proto v1.11.2/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A= 27 31 github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= 28 32 github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= 29 33 github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= ··· 36 40 github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= 37 41 github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= 38 42 github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= 43 + github.com/getkin/kin-openapi v0.120.0 h1:MqJcNJFrMDFNc07iwE8iFC5eT2k/NPUFDIpNeiZv8Jg= 44 + github.com/getkin/kin-openapi v0.120.0/go.mod h1:PCWw/lfBrJY4HcdqE3jj+QFkaFK8ABoqo7PvqVhXXqw= 39 45 github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= 40 46 github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4= 41 47 github.com/go-faker/faker/v4 v4.3.0 h1:UXOW7kn/Mwd0u6MR30JjUKVzguT20EB/hBOddAAO+DY= ··· 48 54 github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= 49 55 github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4= 50 56 github.com/go-git/go-git/v5 v5.11.0/go.mod h1:6GFcX2P3NM7FPBfpePbpLd21XxsgdAt+lKqXmCUiUCY= 57 + github.com/go-openapi/jsonpointer v0.20.0 h1:ESKJdU9ASRfaPNOPRx12IUyA1vn3R9GiE3KYD14BXdQ= 58 + github.com/go-openapi/jsonpointer v0.20.0/go.mod h1:6PGzBjjIIumbLYysB73Klnms1mwnU4G3YHOECG3CedA= 59 + github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= 60 + github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= 51 61 github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= 52 62 github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 53 63 github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= ··· 57 67 github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 58 68 github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= 59 69 github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 70 + github.com/invopop/yaml v0.2.0 h1:7zky/qH+O0DwAyoobXUqvVBwgBFRxKoQ/3FjcVpjTMY= 71 + github.com/invopop/yaml v0.2.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q= 60 72 github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= 61 73 github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= 62 74 github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= 63 75 github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= 76 + github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= 77 + github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= 64 78 github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= 65 79 github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= 66 80 github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= ··· 70 84 github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 71 85 github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= 72 86 github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= 87 + github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= 88 + github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= 89 + github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= 90 + github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= 73 91 github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= 74 92 github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= 93 + github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s= 94 + github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw= 75 95 github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= 76 96 github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= 77 97 github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= ··· 182 202 gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= 183 203 gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 184 204 gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 205 + gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 185 206 gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 186 207 gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 187 208 tailscale.com v1.58.2 h1:5trkhh/fpUn7f6TUcGUQYJ0GokdNNfNrjh9ONJhoc5A=
+33
gomod2nix.toml
··· 13 13 [mod."github.com/bep/debounce"] 14 14 version = "v1.2.1" 15 15 hash = "sha256-7qHOp4vB0ifEseXXBuSH6W5YNImVcb8PTWSJJAMaGcU=" 16 + [mod."github.com/blockthrough/twirp-openapi-gen"] 17 + version = "v0.0.0-20231107141308-45a52eb7d856" 18 + hash = "sha256-i0K4rM/A36eTIG86zibtaA40WoT2M+ptReRCDy+EYGs=" 16 19 [mod."github.com/cloudflare/circl"] 17 20 version = "v1.3.7" 18 21 hash = "sha256-AkOpcZ+evLxLJStvvr01+TLeWDqcLxY3e/AhGggzh40=" ··· 22 25 [mod."github.com/donatj/hmacsig"] 23 26 version = "v1.1.0" 24 27 hash = "sha256-/T7mWqQwZt+AFD/2QAYCAW/TsZptawFMl8CGWPmyhtE=" 28 + [mod."github.com/emicklei/proto"] 29 + version = "v1.11.2" 30 + hash = "sha256-1j9oAuZbq5F+eY0emvivv4G/46YRoL/QzqwomuFElsw=" 25 31 [mod."github.com/emirpasic/gods"] 26 32 version = "v1.18.1" 27 33 hash = "sha256-hGDKddjLj+5dn2woHtXKUdd49/3xdsqnhx7VEdCu1m4=" ··· 34 40 [mod."github.com/facebookgo/subset"] 35 41 version = "v0.0.0-20200203212716-c811ad88dec4" 36 42 hash = "sha256-oBhWz9Haw/ZuqJofQ7psThNrr1f6GHHgxq8agev7TOo=" 43 + [mod."github.com/getkin/kin-openapi"] 44 + version = "v0.120.0" 45 + hash = "sha256-x5BjdRncVOy3t7HqmA6IwfYDg/xy3BsGjFawrnrXcko=" 37 46 [mod."github.com/go-faker/faker/v4"] 38 47 version = "v4.3.0" 39 48 hash = "sha256-Y70kJJAMfQ6CBvZO+28gpKGSni/EFMNIGKUzc299Sss=" ··· 46 55 [mod."github.com/go-git/go-git/v5"] 47 56 version = "v5.11.0" 48 57 hash = "sha256-2yUM/FlV+nYxacVynJCnDZeMub4Iu8JL2WBHmlnwOkE=" 58 + [mod."github.com/go-openapi/jsonpointer"] 59 + version = "v0.20.0" 60 + hash = "sha256-31YT6a8u7adrtEOV62066BrrNfPT5kg5uUUo9ULW0Qk=" 61 + [mod."github.com/go-openapi/swag"] 62 + version = "v0.22.4" 63 + hash = "sha256-a3iJF2d9pJVTBMNpxWIOA8S1+qTbQQ+ToFcXypQ5Tec=" 49 64 [mod."github.com/golang/groupcache"] 50 65 version = "v0.0.0-20210331224755-41bb18bfe9da" 51 66 hash = "sha256-7Gs7CS9gEYZkbu5P4hqPGBpeGZWC64VDwraSKFF+VR0=" 52 67 [mod."github.com/golang/protobuf"] 53 68 version = "v1.5.3" 54 69 hash = "sha256-svogITcP4orUIsJFjMtp+Uv1+fKJv2Q5Zwf2dMqnpOQ=" 70 + [mod."github.com/invopop/yaml"] 71 + version = "v0.2.0" 72 + hash = "sha256-RxeDuvwOSWYaLc8Q7T39rfFT3bZX3g9Bu0RFwxH6sLw=" 55 73 [mod."github.com/jbenet/go-context"] 56 74 version = "v0.0.0-20150711004518-d14ea06fba99" 57 75 hash = "sha256-VANNCWNNpARH/ILQV9sCQsBWgyL2iFT+4AHZREpxIWE=" 58 76 [mod."github.com/joho/godotenv"] 59 77 version = "v1.5.1" 60 78 hash = "sha256-kA0osKfsc6Kp+nuGTRJyXZZlJt1D/kuEazKMWYCWcQ8=" 79 + [mod."github.com/josharian/intern"] 80 + version = "v1.0.0" 81 + hash = "sha256-LJR0QE2vOQ2/2shBbO5Yl8cVPq+NFrE3ers0vu9FRP0=" 61 82 [mod."github.com/kevinburke/ssh_config"] 62 83 version = "v1.2.0" 63 84 hash = "sha256-Ta7ZOmyX8gG5tzWbY2oES70EJPfI90U7CIJS9EAce0s=" 85 + [mod."github.com/mailru/easyjson"] 86 + version = "v0.7.7" 87 + hash = "sha256-NVCz8MURpxgOjHXqxOZExqV4bnpHggpeAOyZDArjcy4=" 88 + [mod."github.com/mohae/deepcopy"] 89 + version = "v0.0.0-20170929034955-c48cc78d4826" 90 + hash = "sha256-TQMmKqIYwVhmMVh4RYQkAui97Eyj7poLmcAuDcHXsEk=" 91 + [mod."github.com/perimeterx/marshmallow"] 92 + version = "v1.1.5" 93 + hash = "sha256-fFWjg0FNohDSV0/wUjQ8fBq1g8h6yIqTrHkxqL2Tt0s=" 64 94 [mod."github.com/pjbgf/sha1cd"] 65 95 version = "v0.3.0" 66 96 hash = "sha256-kX9BdLh2dxtGNaDvc24NORO+C0AZ7JzbrXrtecCdB7w=" ··· 115 145 [mod."gopkg.in/warnings.v0"] 116 146 version = "v0.1.2" 117 147 hash = "sha256-ATVL9yEmgYbkJ1DkltDGRn/auGAjqGOfjQyBYyUo8s8=" 148 + [mod."gopkg.in/yaml.v3"] 149 + version = "v3.0.1" 150 + hash = "sha256-FqL9TKYJ0XkNwJFnq9j0VvJ5ZUU1RvH/52h/f5bkYAU=" 118 151 [mod."tailscale.com"] 119 152 version = "v1.58.2" 120 153 hash = "sha256-ok+xgZRbFkQcH9VR75bhHx+bRn8ymoYQeBYsMpvfGss="
+24
internal/lume/lume.go
··· 69 69 70 70 fs fs.FS 71 71 lock sync.Mutex 72 + 73 + lastBuildTime time.Time 72 74 } 73 75 74 76 func (f *FS) Close() error { ··· 84 86 } 85 87 86 88 return nil 89 + } 90 + 91 + func (f *FS) Commit() (string, error) { 92 + f.lock.Lock() 93 + defer f.lock.Unlock() 94 + 95 + commit, err := f.repo.Head() 96 + if err != nil { 97 + return "", fmt.Errorf("lume: can't get head: %w", err) 98 + } 99 + 100 + result := commit.Hash().String() 101 + 102 + return result, nil 103 + } 104 + 105 + func (f *FS) BuildTime() time.Time { 106 + f.lock.Lock() 107 + defer f.lock.Unlock() 108 + 109 + return f.lastBuildTime 87 110 } 88 111 89 112 func (f *FS) Open(name string) (fs.File, error) { ··· 205 228 } 206 229 }() 207 230 } 231 + fs.lastBuildTime = time.Now() 208 232 209 233 return fs, nil 210 234 }
+8
pb/generate.go
··· 1 1 package pb 2 2 3 + import ( 4 + "embed" 5 + ) 6 + 3 7 func init() {} 4 8 5 9 //go:generate protoc --proto_path=. --go_out=. --go_opt=paths=source_relative --twirp_out=. --twirp_opt=paths=source_relative xesite.proto 10 + //go:generate go run github.com/blockthrough/twirp-openapi-gen/cmd/twirp-openapi-gen --in=xesite.proto --path-prefix=/api --servers=https://xeiaso.net --title="xeiaso.net API" --out openapi.json 11 + 12 + //go:embed xesite.proto openapi.json 13 + var Proto embed.FS
+61
pb/openapi.json
··· 1 + { 2 + "components": { 3 + "schemas": { 4 + "xeiaso.net.BuildInfo": { 5 + "properties": { 6 + "build_time": { 7 + "format": "date-time", 8 + "type": "string" 9 + }, 10 + "commit": { 11 + "type": "string" 12 + }, 13 + "deno_version": { 14 + "type": "string" 15 + }, 16 + "go_version": { 17 + "type": "string" 18 + }, 19 + "xesite_version": { 20 + "type": "string" 21 + } 22 + }, 23 + "type": "object" 24 + } 25 + } 26 + }, 27 + "info": { 28 + "title": "xeiaso.net API", 29 + "version": "0.1" 30 + }, 31 + "openapi": "3.0.0", 32 + "paths": { 33 + "/api/xeiaso.net.Meta/Metadata": { 34 + "post": { 35 + "requestBody": { 36 + "content": { 37 + "application/json": {} 38 + } 39 + }, 40 + "responses": { 41 + "200": { 42 + "content": { 43 + "application/json": { 44 + "schema": { 45 + "$ref": "#/components/schemas/xeiaso.net.BuildInfo" 46 + } 47 + } 48 + }, 49 + "description": "Success" 50 + } 51 + }, 52 + "summary": "Metadata" 53 + } 54 + } 55 + }, 56 + "servers": [ 57 + { 58 + "url": "https://xeiaso.net" 59 + } 60 + ] 61 + }
+25 -14
pb/xesite.pb.go
··· 27 27 sizeCache protoimpl.SizeCache 28 28 unknownFields protoimpl.UnknownFields 29 29 30 - Commit string `protobuf:"bytes,1,opt,name=commit,proto3" json:"commit,omitempty"` 31 - BuildTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=build_time,json=buildTime,proto3" json:"build_time,omitempty"` 32 - GoVersion string `protobuf:"bytes,3,opt,name=go_version,json=goVersion,proto3" json:"go_version,omitempty"` 33 - DenoVersion string `protobuf:"bytes,4,opt,name=deno_version,json=denoVersion,proto3" json:"deno_version,omitempty"` 30 + Commit string `protobuf:"bytes,1,opt,name=commit,proto3" json:"commit,omitempty"` 31 + BuildTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=build_time,json=buildTime,proto3" json:"build_time,omitempty"` 32 + GoVersion string `protobuf:"bytes,3,opt,name=go_version,json=goVersion,proto3" json:"go_version,omitempty"` 33 + DenoVersion string `protobuf:"bytes,4,opt,name=deno_version,json=denoVersion,proto3" json:"deno_version,omitempty"` 34 + XesiteVersion string `protobuf:"bytes,5,opt,name=xesite_version,json=xesiteVersion,proto3" json:"xesite_version,omitempty"` 34 35 } 35 36 36 37 func (x *BuildInfo) Reset() { ··· 93 94 return "" 94 95 } 95 96 97 + func (x *BuildInfo) GetXesiteVersion() string { 98 + if x != nil { 99 + return x.XesiteVersion 100 + } 101 + return "" 102 + } 103 + 96 104 var File_xesite_proto protoreflect.FileDescriptor 97 105 98 106 var file_xesite_proto_rawDesc = []byte{ ··· 101 109 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 102 110 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 103 111 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 104 - 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa0, 0x01, 0x0a, 0x09, 0x42, 0x75, 0x69, 112 + 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc7, 0x01, 0x0a, 0x09, 0x42, 0x75, 0x69, 105 113 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 106 114 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x39, 107 115 0x0a, 0x0a, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, ··· 111 119 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x67, 112 120 0x6f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x65, 0x6e, 0x6f, 113 121 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 114 - 0x64, 0x65, 0x6e, 0x6f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x32, 0x41, 0x0a, 0x04, 0x4c, 115 - 0x75, 0x6d, 0x65, 0x12, 0x39, 0x0a, 0x08, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 116 - 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 117 - 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x15, 0x2e, 0x78, 0x65, 0x69, 0x61, 0x73, 0x6f, 118 - 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x42, 0x12, 119 - 0x5a, 0x10, 0x78, 0x65, 0x69, 0x61, 0x73, 0x6f, 0x2e, 0x6e, 0x65, 0x74, 0x2f, 0x76, 0x34, 0x2f, 120 - 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 122 + 0x64, 0x65, 0x6e, 0x6f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x0a, 0x0e, 0x78, 123 + 0x65, 0x73, 0x69, 0x74, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 124 + 0x01, 0x28, 0x09, 0x52, 0x0d, 0x78, 0x65, 0x73, 0x69, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 125 + 0x6f, 0x6e, 0x32, 0x41, 0x0a, 0x04, 0x4d, 0x65, 0x74, 0x61, 0x12, 0x39, 0x0a, 0x08, 0x4d, 0x65, 126 + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 127 + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x15, 128 + 0x2e, 0x78, 0x65, 0x69, 0x61, 0x73, 0x6f, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x42, 0x75, 0x69, 0x6c, 129 + 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x42, 0x12, 0x5a, 0x10, 0x78, 0x65, 0x69, 0x61, 0x73, 0x6f, 0x2e, 130 + 0x6e, 0x65, 0x74, 0x2f, 0x76, 0x34, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 131 + 0x33, 121 132 } 122 133 123 134 var ( ··· 140 151 } 141 152 var file_xesite_proto_depIdxs = []int32{ 142 153 1, // 0: xeiaso.net.BuildInfo.build_time:type_name -> google.protobuf.Timestamp 143 - 2, // 1: xeiaso.net.Lume.Metadata:input_type -> google.protobuf.Empty 144 - 0, // 2: xeiaso.net.Lume.Metadata:output_type -> xeiaso.net.BuildInfo 154 + 2, // 1: xeiaso.net.Meta.Metadata:input_type -> google.protobuf.Empty 155 + 0, // 2: xeiaso.net.Meta.Metadata:output_type -> xeiaso.net.BuildInfo 145 156 2, // [2:3] is the sub-list for method output_type 146 157 1, // [1:2] is the sub-list for method input_type 147 158 1, // [1:1] is the sub-list for extension type_name
+1 -1
pb/xesite.proto
··· 5 5 import "google/protobuf/empty.proto"; 6 6 import "google/protobuf/timestamp.proto"; 7 7 8 - service Lume { rpc Metadata(google.protobuf.Empty) returns (BuildInfo); } 8 + service Meta { rpc Metadata(google.protobuf.Empty) returns (BuildInfo); } 9 9 10 10 message BuildInfo { 11 11 string commit = 1;
+62 -61
pb/xesite.twirp.go
··· 30 30 const _ = twirp.TwirpPackageMinVersion_8_1_0 31 31 32 32 // ============== 33 - // Lume Interface 33 + // Meta Interface 34 34 // ============== 35 35 36 - type Lume interface { 36 + type Meta interface { 37 37 Metadata(context.Context, *google_protobuf.Empty) (*BuildInfo, error) 38 38 } 39 39 40 40 // ==================== 41 - // Lume Protobuf Client 41 + // Meta Protobuf Client 42 42 // ==================== 43 43 44 - type lumeProtobufClient struct { 44 + type metaProtobufClient struct { 45 45 client HTTPClient 46 46 urls [1]string 47 47 interceptor twirp.Interceptor 48 48 opts twirp.ClientOptions 49 49 } 50 50 51 - // NewLumeProtobufClient creates a Protobuf client that implements the Lume interface. 51 + // NewMetaProtobufClient creates a Protobuf client that implements the Meta interface. 52 52 // It communicates using Protobuf and can be configured with a custom HTTPClient. 53 - func NewLumeProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Lume { 53 + func NewMetaProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Meta { 54 54 if c, ok := client.(*http.Client); ok { 55 55 client = withoutRedirects(c) 56 56 } ··· 70 70 71 71 // Build method URLs: <baseURL>[<prefix>]/<package>.<Service>/<Method> 72 72 serviceURL := sanitizeBaseURL(baseURL) 73 - serviceURL += baseServicePath(pathPrefix, "xeiaso.net", "Lume") 73 + serviceURL += baseServicePath(pathPrefix, "xeiaso.net", "Meta") 74 74 urls := [1]string{ 75 75 serviceURL + "Metadata", 76 76 } 77 77 78 - return &lumeProtobufClient{ 78 + return &metaProtobufClient{ 79 79 client: client, 80 80 urls: urls, 81 81 interceptor: twirp.ChainInterceptors(clientOpts.Interceptors...), ··· 83 83 } 84 84 } 85 85 86 - func (c *lumeProtobufClient) Metadata(ctx context.Context, in *google_protobuf.Empty) (*BuildInfo, error) { 86 + func (c *metaProtobufClient) Metadata(ctx context.Context, in *google_protobuf.Empty) (*BuildInfo, error) { 87 87 ctx = ctxsetters.WithPackageName(ctx, "xeiaso.net") 88 - ctx = ctxsetters.WithServiceName(ctx, "Lume") 88 + ctx = ctxsetters.WithServiceName(ctx, "Meta") 89 89 ctx = ctxsetters.WithMethodName(ctx, "Metadata") 90 90 caller := c.callMetadata 91 91 if c.interceptor != nil { ··· 112 112 return caller(ctx, in) 113 113 } 114 114 115 - func (c *lumeProtobufClient) callMetadata(ctx context.Context, in *google_protobuf.Empty) (*BuildInfo, error) { 115 + func (c *metaProtobufClient) callMetadata(ctx context.Context, in *google_protobuf.Empty) (*BuildInfo, error) { 116 116 out := new(BuildInfo) 117 117 ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out) 118 118 if err != nil { ··· 130 130 } 131 131 132 132 // ================ 133 - // Lume JSON Client 133 + // Meta JSON Client 134 134 // ================ 135 135 136 - type lumeJSONClient struct { 136 + type metaJSONClient struct { 137 137 client HTTPClient 138 138 urls [1]string 139 139 interceptor twirp.Interceptor 140 140 opts twirp.ClientOptions 141 141 } 142 142 143 - // NewLumeJSONClient creates a JSON client that implements the Lume interface. 143 + // NewMetaJSONClient creates a JSON client that implements the Meta interface. 144 144 // It communicates using JSON and can be configured with a custom HTTPClient. 145 - func NewLumeJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Lume { 145 + func NewMetaJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Meta { 146 146 if c, ok := client.(*http.Client); ok { 147 147 client = withoutRedirects(c) 148 148 } ··· 162 162 163 163 // Build method URLs: <baseURL>[<prefix>]/<package>.<Service>/<Method> 164 164 serviceURL := sanitizeBaseURL(baseURL) 165 - serviceURL += baseServicePath(pathPrefix, "xeiaso.net", "Lume") 165 + serviceURL += baseServicePath(pathPrefix, "xeiaso.net", "Meta") 166 166 urls := [1]string{ 167 167 serviceURL + "Metadata", 168 168 } 169 169 170 - return &lumeJSONClient{ 170 + return &metaJSONClient{ 171 171 client: client, 172 172 urls: urls, 173 173 interceptor: twirp.ChainInterceptors(clientOpts.Interceptors...), ··· 175 175 } 176 176 } 177 177 178 - func (c *lumeJSONClient) Metadata(ctx context.Context, in *google_protobuf.Empty) (*BuildInfo, error) { 178 + func (c *metaJSONClient) Metadata(ctx context.Context, in *google_protobuf.Empty) (*BuildInfo, error) { 179 179 ctx = ctxsetters.WithPackageName(ctx, "xeiaso.net") 180 - ctx = ctxsetters.WithServiceName(ctx, "Lume") 180 + ctx = ctxsetters.WithServiceName(ctx, "Meta") 181 181 ctx = ctxsetters.WithMethodName(ctx, "Metadata") 182 182 caller := c.callMetadata 183 183 if c.interceptor != nil { ··· 204 204 return caller(ctx, in) 205 205 } 206 206 207 - func (c *lumeJSONClient) callMetadata(ctx context.Context, in *google_protobuf.Empty) (*BuildInfo, error) { 207 + func (c *metaJSONClient) callMetadata(ctx context.Context, in *google_protobuf.Empty) (*BuildInfo, error) { 208 208 out := new(BuildInfo) 209 209 ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out) 210 210 if err != nil { ··· 222 222 } 223 223 224 224 // =================== 225 - // Lume Server Handler 225 + // Meta Server Handler 226 226 // =================== 227 227 228 - type lumeServer struct { 229 - Lume 228 + type metaServer struct { 229 + Meta 230 230 interceptor twirp.Interceptor 231 231 hooks *twirp.ServerHooks 232 232 pathPrefix string // prefix for routing ··· 234 234 jsonCamelCase bool // JSON fields are serialized as lowerCamelCase rather than keeping the original proto names 235 235 } 236 236 237 - // NewLumeServer builds a TwirpServer that can be used as an http.Handler to handle 237 + // NewMetaServer builds a TwirpServer that can be used as an http.Handler to handle 238 238 // HTTP requests that are routed to the right method in the provided svc implementation. 239 239 // The opts are twirp.ServerOption modifiers, for example twirp.WithServerHooks(hooks). 240 - func NewLumeServer(svc Lume, opts ...interface{}) TwirpServer { 240 + func NewMetaServer(svc Meta, opts ...interface{}) TwirpServer { 241 241 serverOpts := newServerOpts(opts) 242 242 243 243 // Using ReadOpt allows backwards and forwards compatibility with new options in the future ··· 250 250 pathPrefix = "/twirp" // default prefix 251 251 } 252 252 253 - return &lumeServer{ 254 - Lume: svc, 253 + return &metaServer{ 254 + Meta: svc, 255 255 hooks: serverOpts.Hooks, 256 256 interceptor: twirp.ChainInterceptors(serverOpts.Interceptors...), 257 257 pathPrefix: pathPrefix, ··· 262 262 263 263 // writeError writes an HTTP response with a valid Twirp error format, and triggers hooks. 264 264 // If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err) 265 - func (s *lumeServer) writeError(ctx context.Context, resp http.ResponseWriter, err error) { 265 + func (s *metaServer) writeError(ctx context.Context, resp http.ResponseWriter, err error) { 266 266 writeError(ctx, resp, err, s.hooks) 267 267 } 268 268 269 269 // handleRequestBodyError is used to handle error when the twirp server cannot read request 270 - func (s *lumeServer) handleRequestBodyError(ctx context.Context, resp http.ResponseWriter, msg string, err error) { 270 + func (s *metaServer) handleRequestBodyError(ctx context.Context, resp http.ResponseWriter, msg string, err error) { 271 271 if context.Canceled == ctx.Err() { 272 272 s.writeError(ctx, resp, twirp.NewError(twirp.Canceled, "failed to read request: context canceled")) 273 273 return ··· 279 279 s.writeError(ctx, resp, twirp.WrapError(malformedRequestError(msg), err)) 280 280 } 281 281 282 - // LumePathPrefix is a convenience constant that may identify URL paths. 282 + // MetaPathPrefix is a convenience constant that may identify URL paths. 283 283 // Should be used with caution, it only matches routes generated by Twirp Go clients, 284 284 // with the default "/twirp" prefix and default CamelCase service and method names. 285 285 // More info: https://twitchtv.github.io/twirp/docs/routing.html 286 - const LumePathPrefix = "/twirp/xeiaso.net.Lume/" 286 + const MetaPathPrefix = "/twirp/xeiaso.net.Meta/" 287 287 288 - func (s *lumeServer) ServeHTTP(resp http.ResponseWriter, req *http.Request) { 288 + func (s *metaServer) ServeHTTP(resp http.ResponseWriter, req *http.Request) { 289 289 ctx := req.Context() 290 290 ctx = ctxsetters.WithPackageName(ctx, "xeiaso.net") 291 - ctx = ctxsetters.WithServiceName(ctx, "Lume") 291 + ctx = ctxsetters.WithServiceName(ctx, "Meta") 292 292 ctx = ctxsetters.WithResponseWriter(ctx, resp) 293 293 294 294 var err error ··· 306 306 307 307 // Verify path format: [<prefix>]/<package>.<Service>/<Method> 308 308 prefix, pkgService, method := parseTwirpPath(req.URL.Path) 309 - if pkgService != "xeiaso.net.Lume" { 309 + if pkgService != "xeiaso.net.Meta" { 310 310 msg := fmt.Sprintf("no handler for path %q", req.URL.Path) 311 311 s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) 312 312 return ··· 328 328 } 329 329 } 330 330 331 - func (s *lumeServer) serveMetadata(ctx context.Context, resp http.ResponseWriter, req *http.Request) { 331 + func (s *metaServer) serveMetadata(ctx context.Context, resp http.ResponseWriter, req *http.Request) { 332 332 header := req.Header.Get("Content-Type") 333 333 i := strings.Index(header, ";") 334 334 if i == -1 { ··· 346 346 } 347 347 } 348 348 349 - func (s *lumeServer) serveMetadataJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { 349 + func (s *metaServer) serveMetadataJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { 350 350 var err error 351 351 ctx = ctxsetters.WithMethodName(ctx, "Metadata") 352 352 ctx, err = callRequestRouted(ctx, s.hooks) ··· 368 368 return 369 369 } 370 370 371 - handler := s.Lume.Metadata 371 + handler := s.Meta.Metadata 372 372 if s.interceptor != nil { 373 373 handler = func(ctx context.Context, req *google_protobuf.Empty) (*BuildInfo, error) { 374 374 resp, err := s.interceptor( ··· 377 377 if !ok { 378 378 return nil, twirp.InternalError("failed type assertion req.(*google_protobuf.Empty) when calling interceptor") 379 379 } 380 - return s.Lume.Metadata(ctx, typedReq) 380 + return s.Meta.Metadata(ctx, typedReq) 381 381 }, 382 382 )(ctx, req) 383 383 if resp != nil { ··· 429 429 callResponseSent(ctx, s.hooks) 430 430 } 431 431 432 - func (s *lumeServer) serveMetadataProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { 432 + func (s *metaServer) serveMetadataProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { 433 433 var err error 434 434 ctx = ctxsetters.WithMethodName(ctx, "Metadata") 435 435 ctx, err = callRequestRouted(ctx, s.hooks) ··· 449 449 return 450 450 } 451 451 452 - handler := s.Lume.Metadata 452 + handler := s.Meta.Metadata 453 453 if s.interceptor != nil { 454 454 handler = func(ctx context.Context, req *google_protobuf.Empty) (*BuildInfo, error) { 455 455 resp, err := s.interceptor( ··· 458 458 if !ok { 459 459 return nil, twirp.InternalError("failed type assertion req.(*google_protobuf.Empty) when calling interceptor") 460 460 } 461 - return s.Lume.Metadata(ctx, typedReq) 461 + return s.Meta.Metadata(ctx, typedReq) 462 462 }, 463 463 )(ctx, req) 464 464 if resp != nil { ··· 508 508 callResponseSent(ctx, s.hooks) 509 509 } 510 510 511 - func (s *lumeServer) ServiceDescriptor() ([]byte, int) { 511 + func (s *metaServer) ServiceDescriptor() ([]byte, int) { 512 512 return twirpFileDescriptor0, 0 513 513 } 514 514 515 - func (s *lumeServer) ProtocGenTwirpVersion() string { 515 + func (s *metaServer) ProtocGenTwirpVersion() string { 516 516 return "v8.1.3" 517 517 } 518 518 519 519 // PathPrefix returns the base service path, in the form: "/<prefix>/<package>.<Service>/" 520 520 // that is everything in a Twirp route except for the <Method>. This can be used for routing, 521 521 // for example to identify the requests that are targeted to this service in a mux. 522 - func (s *lumeServer) PathPrefix() string { 523 - return baseServicePath(s.pathPrefix, "xeiaso.net", "Lume") 522 + func (s *metaServer) PathPrefix() string { 523 + return baseServicePath(s.pathPrefix, "xeiaso.net", "Meta") 524 524 } 525 525 526 526 // ===== ··· 1089 1089 } 1090 1090 1091 1091 var twirpFileDescriptor0 = []byte{ 1092 - // 246 bytes of a gzipped FileDescriptorProto 1092 + // 258 bytes of a gzipped FileDescriptorProto 1093 1093 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x90, 0xc1, 0x4a, 0xc3, 0x40, 1094 - 0x10, 0x86, 0x89, 0x96, 0x62, 0xa6, 0x3d, 0xc8, 0x80, 0x25, 0x44, 0xc4, 0xea, 0xa9, 0xa7, 0x0d, 1095 - 0x54, 0x2f, 0x3d, 0x5a, 0xf0, 0x20, 0xe8, 0xa5, 0x88, 0x07, 0x2f, 0x65, 0x63, 0xa6, 0x61, 0xa1, 1096 - 0x9b, 0x09, 0xcd, 0xa4, 0xd4, 0xb7, 0xf1, 0x51, 0x65, 0x77, 0x1b, 0x03, 0xf6, 0x38, 0xff, 0x7c, 1097 - 0xf3, 0x2d, 0xff, 0xc2, 0xf8, 0x40, 0x8d, 0x11, 0x52, 0xf5, 0x8e, 0x85, 0x11, 0x0e, 0x64, 0x74, 1098 - 0xc3, 0xaa, 0x22, 0x49, 0xaf, 0x4b, 0xe6, 0x72, 0x4b, 0x99, 0xdf, 0xe4, 0xed, 0x26, 0x23, 0x5b, 1099 - 0xcb, 0x77, 0x00, 0xd3, 0xdb, 0xff, 0x4b, 0x31, 0x96, 0x1a, 0xd1, 0xb6, 0x0e, 0xc0, 0xfd, 0x4f, 1100 - 0x04, 0xf1, 0xb2, 0x35, 0xdb, 0xe2, 0xa5, 0xda, 0x30, 0x4e, 0x60, 0xf8, 0xc5, 0xd6, 0x1a, 0x49, 1101 - 0xa2, 0x69, 0x34, 0x8b, 0x57, 0xc7, 0x09, 0x17, 0x00, 0xb9, 0x83, 0xd6, 0xee, 0x3c, 0x39, 0x9b, 1102 - 0x46, 0xb3, 0xd1, 0x3c, 0x55, 0xc1, 0xad, 0x3a, 0xb7, 0x7a, 0xef, 0xdc, 0xab, 0xd8, 0xd3, 0x6e, 1103 - 0xc6, 0x1b, 0x80, 0x92, 0xd7, 0x7b, 0xda, 0x35, 0x86, 0xab, 0xe4, 0xdc, 0x6b, 0xe3, 0x92, 0x3f, 1104 - 0x42, 0x80, 0x77, 0x30, 0x2e, 0xa8, 0xea, 0x81, 0x81, 0x07, 0x46, 0x2e, 0x3b, 0x22, 0xf3, 0x27, 1105 - 0x18, 0xbc, 0xb6, 0x96, 0x70, 0x01, 0x17, 0x6f, 0x24, 0xba, 0xd0, 0xa2, 0x71, 0x72, 0xf2, 0xf8, 1106 - 0xb3, 0x6b, 0x9d, 0x5e, 0xa9, 0xfe, 0x67, 0xd4, 0x5f, 0xaf, 0x25, 0x7e, 0x5e, 0xf6, 0x79, 0xb6, 1107 - 0x7f, 0xcc, 0xea, 0x3c, 0x1f, 0xfa, 0xd3, 0x87, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x93, 0x4b, 1108 - 0xaa, 0x5a, 0x5a, 0x01, 0x00, 0x00, 1094 + 0x10, 0x86, 0x89, 0xd6, 0x62, 0xa6, 0x55, 0x64, 0xc1, 0x12, 0x22, 0x62, 0x15, 0x84, 0x9e, 0x36, 1095 + 0x50, 0xbd, 0xf4, 0x68, 0xc1, 0x83, 0x07, 0x2f, 0x45, 0x3c, 0x78, 0x29, 0x1b, 0x33, 0x0d, 0x0b, 1096 + 0xdd, 0x4c, 0xe8, 0x4e, 0x4b, 0x7d, 0x42, 0x5f, 0x4b, 0x76, 0xb7, 0x49, 0xc0, 0x9e, 0x96, 0xf9, 1097 + 0xe7, 0x9b, 0x8f, 0x9d, 0x81, 0xe1, 0x1e, 0xad, 0x66, 0x94, 0xf5, 0x86, 0x98, 0x04, 0xec, 0x51, 1098 + 0x2b, 0x4b, 0xb2, 0x42, 0x4e, 0x6f, 0x4a, 0xa2, 0x72, 0x8d, 0x99, 0xef, 0xe4, 0xdb, 0x55, 0x86, 1099 + 0xa6, 0xe6, 0x9f, 0x00, 0xa6, 0x77, 0xff, 0x9b, 0xac, 0x0d, 0x5a, 0x56, 0xa6, 0x0e, 0xc0, 0xc3, 1100 + 0x6f, 0x04, 0xf1, 0x7c, 0xab, 0xd7, 0xc5, 0x5b, 0xb5, 0x22, 0x31, 0x82, 0xfe, 0x37, 0x19, 0xa3, 1101 + 0x39, 0x89, 0xc6, 0xd1, 0x24, 0x5e, 0x1c, 0x2a, 0x31, 0x03, 0xc8, 0x1d, 0xb4, 0x74, 0xe3, 0xc9, 1102 + 0xc9, 0x38, 0x9a, 0x0c, 0xa6, 0xa9, 0x0c, 0x6e, 0xd9, 0xb8, 0xe5, 0x47, 0xe3, 0x5e, 0xc4, 0x9e, 1103 + 0x76, 0xb5, 0xb8, 0x05, 0x28, 0x69, 0xb9, 0xc3, 0x8d, 0xd5, 0x54, 0x25, 0xa7, 0x5e, 0x1b, 0x97, 1104 + 0xf4, 0x19, 0x02, 0x71, 0x0f, 0xc3, 0x02, 0xab, 0x0e, 0xe8, 0x79, 0x60, 0xe0, 0xb2, 0x06, 0x79, 1105 + 0x84, 0xcb, 0xb0, 0x7c, 0x0b, 0x9d, 0x79, 0xe8, 0x22, 0xa4, 0x07, 0x6c, 0xfa, 0x02, 0xbd, 0x77, 1106 + 0x64, 0x25, 0x66, 0x70, 0xee, 0xde, 0x42, 0xb1, 0x12, 0xa3, 0xa3, 0x3f, 0xbe, 0xba, 0xe3, 0xa4, 1107 + 0xd7, 0xb2, 0x3b, 0xa0, 0x6c, 0xd7, 0x9f, 0x8b, 0xaf, 0xab, 0x2e, 0xcf, 0x76, 0xcf, 0x59, 0x9d, 1108 + 0xe7, 0x7d, 0x3f, 0xfa, 0xf4, 0x17, 0x00, 0x00, 0xff, 0xff, 0xdc, 0x61, 0x9c, 0x09, 0x81, 0x01, 1109 + 0x00, 0x00, 1109 1110 }
+7
tools.go
··· 1 + //go:build ignore 2 + 3 + package xeiaso 4 + 5 + import ( 6 + _ "github.com/blockthrough/twirp-openapi-gen/cmd/twirp-openapi-gen" 7 + )