Compare commits
4 Commits
fbc6c9ca20
...
9ea200464d
| Author | SHA1 | Date |
|---|---|---|
|
|
9ea200464d | |
|
|
8a1fef487a | |
|
|
ffd3890584 | |
|
|
dd952a1f39 |
|
|
@ -80,7 +80,7 @@ func GetAllGroups() ([]Group, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateGroup(name string, reference string) (*Group, error) {
|
func CreateGroup(name string, reference string) (*Group, error) {
|
||||||
name = normalize.Name(name)
|
name = normalize.Trim(name)
|
||||||
stmt := "INSERT INTO [group] (name, reference) VALUES (?, ?)"
|
stmt := "INSERT INTO [group] (name, reference) VALUES (?, ?)"
|
||||||
result, err := database.Exec(stmt, name, reference)
|
result, err := database.Exec(stmt, name, reference)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,13 @@ func (res *Response) Write(w http.ResponseWriter, r *http.Request) error {
|
||||||
|
|
||||||
if res.SeeOther != "" {
|
if res.SeeOther != "" {
|
||||||
http.Redirect(w, r, res.SeeOther, http.StatusSeeOther)
|
http.Redirect(w, r, res.SeeOther, http.StatusSeeOther)
|
||||||
flash := res.Session.FlashPeek()
|
if res.Session != nil {
|
||||||
if flash != nil {
|
flash := res.Session.FlashPeek()
|
||||||
err := json.NewEncoder(w).Encode(flash)
|
if flash != nil {
|
||||||
if err != nil {
|
err := json.NewEncoder(w).Encode(flash)
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,11 @@ func (s *Session) FlashGet() any {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) FlashPeek() any {
|
func (s *Session) FlashPeek() any {
|
||||||
list, _ := s.inner.Values["_flash"].([]any)
|
flash, ok := s.inner.Values["_flash"]
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
list := flash.([]any)
|
||||||
if len(list) < 1 {
|
if len(list) < 1 {
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue