Add function to refresh session

This commit is contained in:
ekzyis 2023-08-15 21:53:50 +02:00
parent 51d0d1d811
commit 4b4736c68d
1 changed files with 23 additions and 0 deletions

23
session.go Normal file
View File

@ -0,0 +1,23 @@
package sn
import (
"fmt"
"net/http"
)
func RefreshSession() error {
req, err := http.NewRequest("GET", SnUrl+"/api/auth/session", nil)
if err != nil {
err = fmt.Errorf("error preparing SN request: %w", err)
return err
}
req.Header.Set("Cookie", SnAuthCookie)
client := http.DefaultClient
_, err = client.Do(req)
if err != nil {
err = fmt.Errorf("error refreshing SN session: %w", err)
return err
}
return nil
}