otfe/controllers/post.go

67 lines
1.6 KiB
Go
Raw Permalink Normal View History

2022-03-12 18:06:39 +00:00
// package controllers
2022-02-23 12:07:09 +00:00
2022-03-12 18:06:39 +00:00
// import (
// "fmt"
// "net/http"
2022-02-23 12:07:09 +00:00
2022-03-12 18:06:39 +00:00
// "git.technical.kiwi/go/otfe/misc/helpers"
// "git.technical.kiwi/go/otfe/models"
// "github.com/husobee/vestigo"
// )
2022-02-23 12:07:09 +00:00
2022-03-12 18:06:39 +00:00
// //User handlers
// type Post struct {
// Title string
// }
2022-02-23 12:07:09 +00:00
2022-03-12 18:06:39 +00:00
// //Index of posts
// func (p Post) Index(w http.ResponseWriter, r *http.Request) {
// p.Title = "Posts"
// t(w, p, "/post/posts.gtpl")
// }
2022-02-23 12:07:09 +00:00
2022-03-12 18:06:39 +00:00
// //Show given user
// func (p Post) Show(w http.ResponseWriter, r *http.Request) {
// t(w, p, "/post/post.gtpl")
// }
2022-02-23 12:07:09 +00:00
2022-03-12 18:06:39 +00:00
// //New user form
// func (p Post) New(w http.ResponseWriter, r *http.Request) {
// t(w, p, "/post/new.gtpl")
// }
2022-02-23 12:07:09 +00:00
2022-03-12 18:06:39 +00:00
// //Create new a user
// func (p Post) Create(w http.ResponseWriter, r *http.Request) {
// r.ParseForm()
// var user models.User
// var err error
// user.Username = r.Form.Get("username")
// user.Email = r.Form.Get("email")
// user.Password, err = helpers.HashPassword(r.Form.Get("password"))
// helpers.CheckError(err)
// user.Create()
// http.Redirect(w, r, "/user/"+user.Username, http.StatusFound)
2022-02-23 12:07:09 +00:00
2022-03-12 18:06:39 +00:00
// }
2022-02-23 12:07:09 +00:00
2022-03-12 18:06:39 +00:00
// //Edit form
// func (p Post) Edit(w http.ResponseWriter, r *http.Request) {
// var data userData
// data.User.Read("username", vestigo.Param(r, "username"))
2022-02-23 12:07:09 +00:00
2022-03-12 18:06:39 +00:00
// }
2022-02-23 12:07:09 +00:00
2022-03-12 18:06:39 +00:00
// //Update user
// func (p Post) Update(w http.ResponseWriter, r *http.Request) {
2022-02-23 12:07:09 +00:00
2022-03-12 18:06:39 +00:00
// }
2022-02-23 12:07:09 +00:00
2022-03-12 18:06:39 +00:00
// //Delete user
// func (p Post) Delete(w http.ResponseWriter, r *http.Request) {
// fmt.Println("Deleting " + vestigo.Param(r, "username"))
// var user models.User
// user.Delete("username", vestigo.Param(r, "username"))
// http.Redirect(w, r, "/user", http.StatusFound)
2022-02-23 12:07:09 +00:00
2022-03-12 18:06:39 +00:00
// }