forked from cloudflare/cloudflare-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes cloudflare#104. Implements create/update and list Workers endpo…
…ints.
- Loading branch information
Showing
4 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use super::WorkersScript; | ||
|
||
use crate::framework::endpoint::{Endpoint, Method}; | ||
|
||
/// Create Script | ||
/// Makes a blep | ||
/// https://api.cloudflare.com/#worker-script-upload-worker | ||
pub struct CreateScript<'a> { | ||
pub account_identifier: &'a str, | ||
pub script_name: &'a str, | ||
pub script_content: String, | ||
} | ||
|
||
impl<'a> Endpoint<WorkersScript, (), String> for CreateScript<'a> { | ||
fn method(&self) -> Method { | ||
Method::Put | ||
} | ||
fn path(&self) -> String { | ||
format!( | ||
"accounts/{}/workers/scripts/{}", | ||
self.account_identifier, self.script_name | ||
) | ||
} | ||
fn serialized_body(&self) -> Option<String> { | ||
Some(self.script_content.clone()) | ||
} | ||
fn content_type(&self) -> String { | ||
"application/javascript".to_owned() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use super::WorkersScript; | ||
|
||
use crate::framework::endpoint::{Endpoint, Method}; | ||
|
||
/// List Scripts | ||
/// Lists all scripts for a given account | ||
/// https://api.cloudflare.com/#worker-script-list-workers | ||
pub struct ListScripts<'a> { | ||
pub account_identifier: &'a str, | ||
} | ||
|
||
impl<'a> Endpoint<Vec<WorkersScript>> for ListScripts<'a> { | ||
fn method(&self) -> Method { | ||
Method::Get | ||
} | ||
fn path(&self) -> String { | ||
format!( | ||
"accounts/{}/workers/scripts", | ||
self.account_identifier | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters