2022-08-10 05:10:47 +00:00
|
|
|
package index
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2022-08-22 00:56:14 +00:00
|
|
|
"git.kirsle.net/apps/gosocial/pkg/config"
|
2022-08-10 05:10:47 +00:00
|
|
|
"git.kirsle.net/apps/gosocial/pkg/log"
|
|
|
|
"git.kirsle.net/apps/gosocial/pkg/templates"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Create the controller.
|
|
|
|
func Create() http.HandlerFunc {
|
|
|
|
tmpl := templates.Must("index.html")
|
|
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
if r.URL.Path != "/" || r.Method != http.MethodGet {
|
|
|
|
log.Error("404 Not Found: %s", r.URL.Path)
|
|
|
|
templates.NotFoundPage(w, r)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := tmpl.Execute(w, r, nil); err != nil {
|
|
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2022-08-22 00:56:14 +00:00
|
|
|
|
|
|
|
// Favicon
|
|
|
|
func Favicon() http.HandlerFunc {
|
|
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
http.ServeFile(w, r, config.StaticPath+"/favicon.ico")
|
|
|
|
})
|
|
|
|
}
|