mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-11 05:06:51 +00:00
docs: add docstrings
This commit is contained in:
@ -47,6 +47,7 @@ import (
|
||||
|
||||
"github.com/ProtonMail/proton-bridge/internal/api"
|
||||
"github.com/ProtonMail/proton-bridge/internal/bridge"
|
||||
"github.com/ProtonMail/proton-bridge/internal/cookies"
|
||||
"github.com/ProtonMail/proton-bridge/internal/events"
|
||||
"github.com/ProtonMail/proton-bridge/internal/frontend"
|
||||
"github.com/ProtonMail/proton-bridge/internal/imap"
|
||||
@ -56,7 +57,6 @@ import (
|
||||
"github.com/ProtonMail/proton-bridge/pkg/args"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/config"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/constants"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/cookies"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/listener"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/updates"
|
||||
@ -275,7 +275,7 @@ func run(context *cli.Context) (contextError error) { // nolint[funlen]
|
||||
cm.SetRoundTripper(cfg.GetRoundTripper(cm, eventListener))
|
||||
|
||||
// Cookies must be persisted across restarts.
|
||||
jar, err := cookies.New(cookies.NewPersister(pref))
|
||||
jar, err := cookies.NewCookieJar(cookies.NewPersister(pref))
|
||||
if err != nil {
|
||||
logrus.WithError(err).Warn("Could not create cookie jar")
|
||||
} else {
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with ProtonMail Bridge. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
// Package cookies implements a persistent cookie jar which satisfies the http.CookieJar interface.
|
||||
package cookies
|
||||
|
||||
import (
|
||||
@ -26,13 +27,15 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Jar implements http.CookieJar by wrapping the standard library's cookiejar.Jar.
|
||||
// The jar uses a Persister to load cookies at startup and save cookies when set.
|
||||
type Jar struct {
|
||||
jar *cookiejar.Jar
|
||||
persister *Persister
|
||||
locker sync.Locker
|
||||
}
|
||||
|
||||
func New(persister *Persister) (*Jar, error) {
|
||||
func NewCookieJar(persister *Persister) (*Jar, error) {
|
||||
jar, err := cookiejar.New(nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -36,7 +36,7 @@ func TestJar(t *testing.T) {
|
||||
ts := getTestServer(t, testCookies...)
|
||||
defer ts.Close()
|
||||
|
||||
jar, err := New(NewPersister(make(testPersister)))
|
||||
jar, err := NewCookieJar(NewPersister(make(testPersister)))
|
||||
require.NoError(t, err)
|
||||
|
||||
client := &http.Client{Jar: jar}
|
||||
Reference in New Issue
Block a user