Skip to content

Commit

Permalink
Add cf.as_organization function (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
kpcyrd authored Mar 7, 2024
1 parent 3b92e32 commit 9328b29
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions worker-sys/src/types/incoming_request_cf_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ extern "C" {
#[wasm_bindgen(method, getter)]
pub fn asn(this: &IncomingRequestCfProperties) -> u32;

#[wasm_bindgen(method, getter, js_name=asOrganization)]
pub fn as_organization(this: &IncomingRequestCfProperties) -> String;

#[wasm_bindgen(method, getter)]
pub fn country(this: &IncomingRequestCfProperties) -> Option<String>;

Expand Down
5 changes: 5 additions & 0 deletions worker/src/cf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ impl Cf {
self.inner.asn()
}

/// The Autonomous System organization name of the request, e.g. `Cloudflare, Inc.`
pub fn as_organization(&self) -> String {
self.inner.as_organization()
}

/// The two-letter country code of origin for the request.
/// This is the same value as that provided in the CF-IPCountry header, e.g. `"US"`
pub fn country(&self) -> Option<String> {
Expand Down

0 comments on commit 9328b29

Please sign in to comment.