Browse Source

Fix linting errors

tags/v1.0.0
Remco 7 years ago
parent
commit
d0dbdd3591
2 changed files with 9 additions and 9 deletions
  1. +5
    -5
      server/handlers.go
  2. +4
    -4
      server/server.go

+ 5
- 5
server/handlers.go View File

@@ -60,8 +60,8 @@ import (
) )


var ( var (
html_templates = initHTMLTemplates()
text_templates = initTextTemplates()
htmlTemplates = initHTMLTemplates()
textTemplates = initTextTemplates()
) )


func stripPrefix(path string) string { func stripPrefix(path string) string {
@@ -160,7 +160,7 @@ func (s *Server) previewHandler(w http.ResponseWriter, r *http.Request) {
contentLength, contentLength,
} }


if err := html_templates.ExecuteTemplate(w, templatePath, data); err != nil {
if err := htmlTemplates.ExecuteTemplate(w, templatePath, data); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return
} }
@@ -174,12 +174,12 @@ func (s *Server) viewHandler(w http.ResponseWriter, r *http.Request) {
// vars := mux.Vars(r) // vars := mux.Vars(r)


if acceptsHTML(r.Header) { if acceptsHTML(r.Header) {
if err := html_templates.ExecuteTemplate(w, "index.html", nil); err != nil {
if err := htmlTemplates.ExecuteTemplate(w, "index.html", nil); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return
} }
} else { } else {
if err := text_templates.ExecuteTemplate(w, "index.txt", nil); err != nil {
if err := textTemplates.ExecuteTemplate(w, "index.txt", nil); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return
} }


+ 4
- 4
server/server.go View File

@@ -220,8 +220,8 @@ func (s *Server) Run() {


fs = http.Dir(s.webPath) fs = http.Dir(s.webPath)


html_templates, _ = html_templates.ParseGlob(s.webPath + "*.html")
text_templates, _ = text_templates.ParseGlob(s.webPath + "*.txt")
htmlTemplates, _ = htmlTemplates.ParseGlob(s.webPath + "*.html")
textTemplates, _ = textTemplates.ParseGlob(s.webPath + "*.txt")
} else { } else {
fs = &assetfs.AssetFS{ fs = &assetfs.AssetFS{
Asset: web.Asset, Asset: web.Asset,
@@ -238,8 +238,8 @@ func (s *Server) Run() {
log.Panicf("Unable to parse: path=%s, err=%s", path, err) log.Panicf("Unable to parse: path=%s, err=%s", path, err)
} }


html_templates.New(stripPrefix(path)).Parse(string(bytes))
text_templates.New(stripPrefix(path)).Parse(string(bytes))
htmlTemplates.New(stripPrefix(path)).Parse(string(bytes))
textTemplates.New(stripPrefix(path)).Parse(string(bytes))
} }
} }




Loading…
Cancel
Save