parent
7795a04129
commit
497dc08070
@ -0,0 +1,30 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetCookie(r *http.Request, name string) string {
|
||||
cookies := r.Cookies()
|
||||
for _, cookie := range cookies {
|
||||
if cookie.Name == name {
|
||||
return cookie.Value
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
func GetMailServerFromCookie(r *http.Request)*MailServer{
|
||||
auth := GetCookie(r, "auth")
|
||||
if !strings.Contains(auth, "|") {
|
||||
return nil
|
||||
}
|
||||
authStrings := strings.Split(auth, "|")
|
||||
mailServer:=&MailServer{
|
||||
Server:authStrings[0],
|
||||
Email: authStrings[1],
|
||||
Password: authStrings[2],
|
||||
}
|
||||
return mailServer
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"mime"
|
||||
)
|
||||
func main(){
|
||||
dec := new(mime.WordDecoder)
|
||||
header, err := dec.DecodeHeader("=?utf-8?q?=C3=89ric?= <eric@example.org>, =?utf-8?q?Ana=C3=AFs?= <anais@example.org>")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println(header)
|
||||
}
|
Loading…
Reference in new issue