adding the news, man
This commit is contained in:
1 parent
c3b570dd24
commit
673fe6cd69
4 files changed
+67
-14
No files matched your search
@@ -107,6 +107,35 @@ func home(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
func news(w http.ResponseWriter, r *http.Request) {
|
||||
id := authenticatedUser(w, r)
|
||||
account, _ := users.GetAccount(id)
|
||||
|
||||
active_subscription := subscriptions.HasActiveSubscription(id)
|
||||
|
||||
text, err := template.ParseFiles("ui/html/base.html", "ui/html/news.html")
|
||||
if err != nil {
|
||||
http.Error(w, "Internal Server Error", 500)
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
switch r.Method {
|
||||
case http.MethodGet:
|
||||
err := text.Execute(w, TemplateData{AuthenticatedUser: id, Account: account, ActiveSubscription: active_subscription})
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
http.Error(w, "Internal Server Error", 500)
|
||||
}
|
||||
|
||||
case http.MethodPost:
|
||||
err := text.Execute(w, TemplateData{})
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
http.Error(w, "Internal Server Error", 500)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func login(w http.ResponseWriter, r *http.Request) {
|
||||
text, err := template.ParseFiles("ui/html/base.html", "ui/html/login.html")
|
||||
if err != nil {
|
||||
|
||||
@@ -71,6 +71,7 @@ func main() {
|
||||
mux.HandleFunc("/favicon.ico", favicon)
|
||||
|
||||
mux.HandleFunc("/", home)
|
||||
mux.HandleFunc("/news", news)
|
||||
mux.HandleFunc("/login", login)
|
||||
mux.HandleFunc("/logout", logout)
|
||||
mux.HandleFunc("/register", register)
|
||||
|
||||
Reference in new issue
Block a user