Client

Connection lifecycle

DearDiary.connectFunction
connect(base_url; username, password, token)::Client

Build a Client pointed at base_url.

Pass username and password to sign in via POST /auth and store the issued token. Pass token instead to attach an already-issued bearer token. Pass neither when the server runs with auth disabled — the client will work without an Authorization header.

Arguments

  • base_url::AbstractString: Base URL of the server (with or without trailing slash).
  • username::Optional{AbstractString}: Username for sign-in.
  • password::Optional{AbstractString}: Password for sign-in.
  • token::Optional{AbstractString}: Pre-issued bearer token.

Returns

A Client ready to issue authenticated requests.

source
DearDiary.disconnectFunction
disconnect(client::Client)::Nothing

Clear the local token. The server is stateless so this is purely a client-side reset; any copies of the token issued earlier remain valid until they expire.

source
DearDiary.refresh_token!Function
refresh_token!(client::Client)::Client

Call POST /auth/refresh and replace the client's token with the freshly-minted one.

source
DearDiary.whoamiFunction
whoami(client::Client)::UserResponse

Resolve the user behind the current token via GET /auth/me. Also refreshes the cached client.user.

source