MCPcopy Create free account
hub / github.com/ez4o/github-contribution-graph / handleSVGInBackground

Method handleSVGInBackground

src/server/server.go:96–110  ·  view source on GitHub ↗
(r *http.Request, b *rod.Browser)

Source from the content-addressed store, hash-verified

94}
95
96func (s *Server) handleSVGInBackground(r *http.Request, b *rod.Browser) {
97 log.Println("New SVG request in background.")
98
99 page := b.MustPage(fmt.Sprintf("http://localhost:8687/?%s", r.URL.Query().Encode()))
100 defer page.Close()
101 page.MustWaitLoad()
102
103 if page.MustHas("#svg-container") {
104 svg := page.MustElement("#svg-container")
105 svgContent := svg.MustHTML()
106
107 s.c.Set("cachedSvgContent:"+r.URL.Query().Encode(), svgContent, cache.DefaultExpiration)
108 s.c.Set("cachedSvgContent:old:"+r.URL.Query().Encode(), svgContent, 15778463000000000)
109 }
110}
111
112func (s *Server) handleSVG(w http.ResponseWriter, r *http.Request, b *rod.Browser) {
113 if svgContent, found := s.c.Get("cachedSvgContent:" + r.URL.Query().Encode()); found {

Callers 1

handleSVGMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected