Browse Source

Code comments

Volodymyr Tkach 2 years ago
parent
commit
d85bbd0107
1 changed files with 11 additions and 4 deletions
  1. 11 4
      utils/http/helpers/helpers.go

+ 11 - 4
utils/http/helpers/helpers.go

@@ -102,15 +102,22 @@ func SessionStart(w http.ResponseWriter, r *http.Request) (*session.Session, err
 	return sess, err
 	return sess, err
 }
 }
 
 
+// Example:
+//
+// if err = r.ParseForm(); err != nil {
+// 	helpers.RespondAsBadRequest(w, r, err)
+// 	return
+// }
+//
+// if err = helpers.SetLanguageCookie(w, r); err != nil {
+// 		helpers.RespondAsBadRequest(w, r, err)
+// 		return
+// }
 func SetLanguageCookie(w http.ResponseWriter, r *http.Request) error {
 func SetLanguageCookie(w http.ResponseWriter, r *http.Request) error {
 	var clang string
 	var clang string
 	if c, err := r.Cookie("lang"); err == nil {
 	if c, err := r.Cookie("lang"); err == nil {
 		clang = c.Value
 		clang = c.Value
 	}
 	}
-	// if err := r.ParseForm(); err != nil {
-	// 	RespondAsBadRequest(w, r, err)
-	// 	return err
-	// }
 	lang := r.Form.Get("lang")
 	lang := r.Form.Get("lang")
 	if lang != "" && lang != clang {
 	if lang != "" && lang != clang {
 		http.SetCookie(w, &http.Cookie{
 		http.SetCookie(w, &http.Cookie{