Add missing handlers

This commit is contained in:
James Mills
2021-01-30 15:30:48 +10:00
parent 8495ba0319
commit 6756dea93d
3 changed files with 28 additions and 11 deletions

View File

@@ -1,7 +1,6 @@
package internal
import (
"errors"
"fmt"
"html/template"
"net/http"
@@ -17,14 +16,7 @@ import (
)
const (
MediaResolution = 720 // 720x576
AvatarResolution = 360 // 360x360
AsyncTaskLimit = 5
MaxFailedLogins = 3 // By default 3 failed login attempts per 5 minutes
)
var (
ErrFeedImposter = errors.New("error: imposter detected, you do not own this feed")
MaxFailedLogins = 3 // By default 3 failed login attempts per 5 minutes
)
func (s *Server) NotFoundHandler(w http.ResponseWriter, r *http.Request) {
@@ -98,3 +90,27 @@ func (s *Server) PageHandler(name string) httprouter.Handle {
s.render("page", w, ctx)
}
}
// IndexHandler ...
func (s *Server) IndexHandler(name string) httprouter.Handle {
return func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
ctx := NewContext(s.config, s.db, r)
s.render("index", w, ctx)
}
}
// CachedHandler ...
func (s *Server) CachedHandler(name string) httprouter.Handle {
return func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
ctx := NewContext(s.config, s.db, r)
s.render("cached", w, ctx)
}
}
// SearchHandler ...
func (s *Server) SearchHandler(name string) httprouter.Handle {
return func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
ctx := NewContext(s.config, s.db, r)
s.render("search", w, ctx)
}
}

View File

@@ -5,10 +5,11 @@ import (
"net/http"
"strings"
"git.mills.io/prologic/spyda/internal/session"
"github.com/julienschmidt/httprouter"
log "github.com/sirupsen/logrus"
"github.com/steambap/captcha"
"git.mills.io/prologic/spyda/internal/session"
)
// CaptchaHandler ...

View File

@@ -31,7 +31,7 @@ type TemplateManager struct {
funcMap template.FuncMap
}
func NewTemplateManager(conf *Config, blogs *BlogsCache, cache *Cache) (*TemplateManager, error) {
func NewTemplateManager(conf *Config) (*TemplateManager, error) {
templates := make(map[string]*template.Template)
funcMap := sprig.FuncMap()