fix(web): Minor typo of struct and add @ in front of username
This commit is contained in:
parent
56225d85e8
commit
8ff9e56182
3 changed files with 12 additions and 12 deletions
pkg/web
|
@ -5,8 +5,8 @@
|
|||
<meta name="theme-color" content="#26a7de">
|
||||
<link rel="canonical" href="{{ .URL }}">
|
||||
|
||||
<meta property="twitter:site" content="{{ .Username }}">
|
||||
<meta property="twitter:creator" content="{{ .Username }}">
|
||||
<meta property="twitter:site" content="@{{ .Username }}">
|
||||
<meta property="twitter:creator" content="@{{ .Username }}">
|
||||
<meta property="twitter:title" content="{{ .Title }}">
|
||||
{{- range $idx, $e := .Images }}
|
||||
<meta property="twitter:image" content="{{ $e }}">
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<link rel="canonical" href="{{ .URL }}">
|
||||
|
||||
{{- if .Videos }}
|
||||
<meta property="twitter:site" content="{{ .Username }}">
|
||||
<meta property="twitter:creator" content="{{ .Username }}">
|
||||
<meta property="twitter:site" content="@{{ .Username }}">
|
||||
<meta property="twitter:creator" content="@{{ .Username }}">
|
||||
{{- range $idx, $e := .Videos }}
|
||||
<meta property="twitter:player:stream" content="{{ $e }}">
|
||||
<meta property="og:video" content="{{ $e }}">
|
||||
|
|
|
@ -23,7 +23,7 @@ const (
|
|||
//go:embed templates/*.html
|
||||
var templateFiles embed.FS
|
||||
|
||||
type Reponse struct {
|
||||
type Response struct {
|
||||
StatusCode int
|
||||
ContentType string
|
||||
Content string
|
||||
|
@ -34,7 +34,7 @@ type WebServer struct {
|
|||
scraper *ts.Scraper
|
||||
templates *template.Template
|
||||
avatarCache *cache.Cache[string, string]
|
||||
responseCache *cache.Cache[string, Reponse]
|
||||
responseCache *cache.Cache[string, Response]
|
||||
|
||||
Server *http.Server
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ func New(config *config.Config, scraper *ts.Scraper) (*WebServer, error) {
|
|||
scraper,
|
||||
tmpl,
|
||||
cache.New[string, string](),
|
||||
cache.New[string, Reponse](),
|
||||
cache.New[string, Response](),
|
||||
&http.Server{
|
||||
Handler: sm,
|
||||
Addr: fmt.Sprintf(":%d", config.WebPort),
|
||||
|
@ -130,7 +130,7 @@ func (ws WebServer) handleTemplate(w http.ResponseWriter, r *http.Request, id st
|
|||
}
|
||||
|
||||
if !slices.Contains(ws.config.Channels, tweet.Username) {
|
||||
res := Reponse{http.StatusBadRequest, "text/plain", "Bad Request"}
|
||||
res := Response{http.StatusBadRequest, "text/plain", "Bad Request"}
|
||||
ws.responseCache.Set(template+"-"+id, res, TweetCacheTime)
|
||||
response(w, res)
|
||||
return
|
||||
|
@ -182,7 +182,7 @@ func (ws WebServer) handleTemplate(w http.ResponseWriter, r *http.Request, id st
|
|||
return
|
||||
}
|
||||
|
||||
res := Reponse{http.StatusOK, "text/html", tpl.String()}
|
||||
res := Response{http.StatusOK, "text/html", tpl.String()}
|
||||
ws.responseCache.Set(template+"-"+id, res, TweetCacheTime)
|
||||
response(w, res)
|
||||
}
|
||||
|
@ -197,14 +197,14 @@ func validUserAgent(ua string, uas []string) bool {
|
|||
}
|
||||
|
||||
func badRequest(w http.ResponseWriter) {
|
||||
response(w, Reponse{http.StatusBadRequest, "text/plain", "Bad Request"})
|
||||
response(w, Response{http.StatusBadRequest, "text/plain", "Bad Request"})
|
||||
}
|
||||
|
||||
func serverError(w http.ResponseWriter) {
|
||||
response(w, Reponse{http.StatusInternalServerError, "text/plain", "Internal Server Error"})
|
||||
response(w, Response{http.StatusInternalServerError, "text/plain", "Internal Server Error"})
|
||||
}
|
||||
|
||||
func response(w http.ResponseWriter, res Reponse) {
|
||||
func response(w http.ResponseWriter, res Response) {
|
||||
w.WriteHeader(res.StatusCode)
|
||||
w.Header().Set("Content-Type", res.ContentType)
|
||||
fmt.Fprint(w, res.Content)
|
||||
|
|
Loading…
Add table
Reference in a new issue