Skip to main content

LineRequestLog

Struct LineRequestLog 

Source
pub struct LineRequestLog<'a> { /* private fields */ }
Expand description

リクエスト送信直前にコールバックへ渡される情報。

§秘匿情報の扱い

秘匿情報はヘッダー側ボディ側の双方に入り得る。

  • ヘッダー: メッセージング系および一部のログイン系 (例: post_user_v1_deauthorize)は headersAuthorization: Bearer <token> を含む。
  • ボディ: OAuth ログイン系(token / revoke / POST verify / deauthorize)は client_secret / refresh_token / access_token / code などの秘匿情報を body 側に持つ(post_user_v1_deauthorize はヘッダーとボディの 両方に秘匿情報を持つ)。

ログ出力時は headers_redacted でヘッダーを、 body_redacted でボディの既知の秘匿キーをマスクできる。

クエリ文字列に秘匿情報を載せるエンドポイント(GET verify の access_token)もあるため、 クエリは query で生値が、query_redacted で 既知の秘匿キー(access_token 等)をマスクした値が得られる。GET verify の access_token は既定の REDACTED_BODY_KEYS に含まれるため query_redacted で マスクされる。ログ出力時は各 *_redacted ヘルパーを使うこと。

Implementations§

Source§

impl<'a> LineRequestLog<'a>

Source

pub fn method(&self) -> Option<&'a Method>

HTTP メソッド(GET / POST など)。

リクエストの複製(try_clone)や再構築に失敗した場合は None (headers と同じ捕捉契約)。

Source

pub fn path(&self) -> Option<&'a str>

リクエスト URL のパス(例: /v2/bot/message/push)。

リクエストの複製(try_clone)や再構築に失敗した場合は None (headers と同じ捕捉契約)。クエリ文字列は含まない (query を参照)。

Source

pub fn query(&self) -> Option<&'a str>

リクエスト URL の生のクエリ文字列(例: from=20240101&to=20241231)。

None になるのは「クエリ文字列が無い」場合と「リクエストの捕捉に失敗した」場合の 両方。両者を区別したい場合は path を併用する(path()Some なら 捕捉は成功しており、query()None なのは純粋にクエリが無いため)。

⚠ 秘匿情報に注意: クエリに秘匿情報を載せるエンドポイント(GET verify の access_token)があるため、本メソッドの戻り値はマスクされていない生値である。ログ等へ 出力する前に query_redacted でマスクすること。

Source

pub fn query_redacted(&self) -> Option<String>

クエリ文字列(query)の既知の秘匿キーを *** に置換した複製を返す。

マスク対象キーは LineOptions の設定値 (with_redacted_body_keys)、未設定時は REDACTED_BODY_KEYS(access_token 等)。キー比較は大文字小文字を無視する。GET verify の access_token は既定キーに含まれるためマスクされる。クエリが無い/捕捉失敗時は None

§限界(許可リスト方式)

マスクは設定されたキーの完全一致(大文字小文字無視)のみで行う。リストに無いキーは マスクされず素通りする。本メソッドの戻り値を「すべての秘匿情報が除去済み」とみなさないこと。 また、マスクの有無に関わらず内部の redact_queryurl::form_urlencoded で再エンコード するため、秘匿キーを含まないペアも表現が正規化され得る(空白の +%20 など)。生値の 忠実な再現が必要なら query を使うこと。

Source

pub fn headers(&self) -> Option<&'a HeaderMap>

リクエストヘッダー。

リクエストの複製(try_clone)や再構築に失敗した場合は None。これにより 「ヘッダーが空」と「捕捉に失敗」を区別できる。なお現行の全エンドポイントは in-memory なボディ(.json / .form / .query)を使うため try_clone は 失敗せず、通常 None にはならない。

捕捉したヘッダーは RequestBuilder を再構築した時点のもので、送信時に reqwest が 付与する content-length / host などは含まれない。

Source

pub fn body(&self) -> &'a Value

各エンドポイントがログ用に渡す論理表現を JSON 化したもの。

フォームエンコード系エンドポイント(OAuth の token / revoke / POST verify)では 実際の送信形式は application/x-www-form-urlencoded であり、この JSON 表現とは 異なる。ボディを持たない GET(GET verify など)は Value::Null、クエリ系の GET (get_v2_bot_message_aggregation_list / get_v2_bot_insight_message_event_aggregation) は query params を JSON オブジェクト化した値になる(HTTP ボディそのものではなく ログ表現である点に注意)。 シリアライズに失敗した場合は {"_serialize_error": "<理由>"} となり、Value::Null (=ボディ無し)とは区別できる。

Source

pub fn headers_redacted(&self) -> Option<HeaderMap>

Authorization ヘッダー値を *** に置換したヘッダーの複製を返す。

ヘッダーのみをマスクする。OAuth 系のようにボディへ秘匿情報が入る場合は body_redacted を使うこと。捕捉失敗時は None

Source

pub fn body_redacted(&self) -> Value

ボディ(body)の既知の秘匿キーを *** に置換した複製を返す。

マスク対象キーは LineOptions の設定値 (with_redacted_body_keys)、未設定時は REDACTED_BODY_KEYS (client_secret / access_token / refresh_token / code / code_verifier / id_token / userAccessToken)。ネストしたオブジェクト/配列も再帰的に走査する。

§限界(許可リスト方式)

マスクは設定されたキーの完全一致(大文字小文字無視)のみで行う。リストに無いキー、 例えば LINE が将来追加するフィールドや、レスポンス型の #[serde(flatten)] extra 経由で 流れ込む未知の秘匿フィールドはマスクされず素通りする。本メソッドの戻り値を「すべての 秘匿情報が除去済み」とみなさないこと。

Trait Implementations§

Source§

impl<'a> Clone for LineRequestLog<'a>

Source§

fn clone(&self) -> LineRequestLog<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LineRequestLog<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for LineRequestLog<'a>

§

impl<'a> RefUnwindSafe for LineRequestLog<'a>

§

impl<'a> Send for LineRequestLog<'a>

§

impl<'a> Sync for LineRequestLog<'a>

§

impl<'a> Unpin for LineRequestLog<'a>

§

impl<'a> UnsafeUnpin for LineRequestLog<'a>

§

impl<'a> UnwindSafe for LineRequestLog<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more