MCPcopy Index your code
hub / github.com/dnote/dnote / Signout

Function Signout

pkg/cli/client/client.go:597–627  ·  view source on GitHub ↗

Signout deletes a user session on the server side

(ctx context.DnoteCtx, sessionKey string)

Source from the content-addressed store, hash-verified

595
596// Signout deletes a user session on the server side
597func Signout(ctx context.DnoteCtx, sessionKey string) error {
598 // Create a client that shares the transport (and thus rate limiter) from ctx.HTTPClient
599 // but doesn't follow redirects
600 var hc *http.Client
601 if ctx.HTTPClient != nil {
602 hc = &http.Client{
603 Transport: ctx.HTTPClient.Transport,
604 CheckRedirect: func(req *http.Request, via []*http.Request) error {
605 return http.ErrUseLastResponse
606 },
607 }
608 } else {
609 log.Warnf("No HTTP client configured for signout - falling back\n")
610 hc = &http.Client{
611 CheckRedirect: func(req *http.Request, via []*http.Request) error {
612 return http.ErrUseLastResponse
613 },
614 }
615 }
616
617 opts := requestOptions{
618 HTTPClient: hc,
619 ExpectedContentType: &contentTypeNone,
620 }
621 _, err := doAuthorizedReq(ctx, "POST", "/v3/signout", "", &opts)
622 if err != nil {
623 return errors.Wrap(err, "making http request")
624 }
625
626 return nil
627}

Callers 2

DoFunction · 0.92
TestSignOutFunction · 0.85

Calls 2

WarnfFunction · 0.92
doAuthorizedReqFunction · 0.85

Tested by 1

TestSignOutFunction · 0.68