aboutsummaryrefslogtreecommitdiff
path: root/src/user/routes.go
diff options
context:
space:
mode:
authorAlexander Kavon <hawk@alexkavon.com>2023-11-28 05:24:30 -0500
committerAlexander Kavon <hawk@alexkavon.com>2023-11-28 05:24:30 -0500
commit629b0189b7bf20c748a1d37f8803ad0e3ffb8a49 (patch)
tree6692374508230b46be3aee323acd7aa25b3d4a91 /src/user/routes.go
parent7d7059d53891bc1abb284d9b288505a5d406b307 (diff)
working container compose w/database, no more auth package, message template partial, working html template writing, auth routes in user/routes.go
Diffstat (limited to 'src/user/routes.go')
-rw-r--r--src/user/routes.go50
1 files changed, 43 insertions, 7 deletions
diff --git a/src/user/routes.go b/src/user/routes.go
index 791213d..09c53b2 100644
--- a/src/user/routes.go
+++ b/src/user/routes.go
@@ -1,6 +1,7 @@
package user
import (
+ "fmt"
"net/http"
"gitlab.com/alexkavon/newsstand/src/server"
@@ -8,16 +9,33 @@ import (
var Routes = server.Routes{
server.Route{
- Name: "Create",
- Method: "GET",
- Path: "/users/create",
- AuthRequired: false,
- HandlerFunc: Create,
+ Name: "Create",
+ Method: "GET",
+ Path: "/user/create",
+ HandlerFunc: Create,
+ },
+ server.Route{
+ Name: "Store",
+ Method: "POST",
+ Path: "/user",
+ HandlerFunc: Store,
+ },
+ server.Route{
+ Name: "LoginForm",
+ Method: "GET",
+ Path: "/user/auth",
+ HandlerFunc: LoginForm,
+ },
+ server.Route{
+ Name: "Authenticate",
+ Method: "POST",
+ Path: "/user/auth",
+ HandlerFunc: Authenticate,
},
server.Route{
Name: "Me",
Method: "GET",
- Path: "/users/me",
+ Path: "/user/me",
AuthRequired: true,
HandlerFunc: Show,
},
@@ -25,10 +43,28 @@ var Routes = server.Routes{
func Create(s *server.Server) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
- s.Ui.Render(w, "users/create", nil)
+ s.Ui.Render(w, "user/create", nil)
+ }
+}
+
+func Store(s *server.Server) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {
+ r.ParseForm()
+ fmt.Println(r.PostForm)
+ s.Ui.Render(w, "core/messages", &struct{ Message string }{Message: "Congrats"})
}
}
+func LoginForm(s *server.Server) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {
+ s.Ui.Render(w, "user/login", nil)
+ }
+}
+
+func Authenticate(s *server.Server) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {}
+}
+
func Show(s *server.Server) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {}
}