Skip to content

Commit

Permalink
fix: add global_vars
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangymPerson committed Jun 12, 2024
1 parent e197e59 commit 7a35003
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions packages/curl/0.1.0/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,64 @@
name: curl
parent: default

global_vars:
- name: protocol
type: choice
params:
values:
- "http"
- "https"

- name: curlform
type: form
params:
layout: Target {{protocol}}://[[URL]]

matches:
- trigger: ":curl:"
replace: "curl --request GET https://example.com"
replace: "curl --request GET {{protocol}}://{{curlform.URL}}"

- trigger: ":curlget:"
replace: "curl --request GET https://example.com?key=value"
replace: "curl --request GET {{protocol}}://{{curlform.URL}}?key=value"

- trigger: ":curlpost:"
replace: "curl --request POST https://example.com"
replace: "curl --request POST {{protocol}}://{{curlform.URL}}"

- trigger: ":curlput:"
replace: "curl --request PUT https://example.com"
replace: "curl --request PUT {{protocol}}://{{curlform.URL}}"

- trigger: ":curldelete:"
replace: "curl --request DELETE https://example.com"
replace: "curl --request DELETE {{protocol}}://{{curlform.URL}}"

- trigger: ":curlpatch:"
replace: "curl --request PATCH https://example.com"
replace: "curl --request PATCH {{protocol}}://{{curlform.URL}}"

- trigger: ":curldata:"
replace: "curl --request POST --header 'Content-Type: multipart/form-data' --form 'key=value' http://example.com"
replace: "curl --request POST --header 'Content-Type: multipart/form-data' --form 'key=value' {{protocol}}://{{curlform.URL}}"

- trigger: ":curlxml:"
replace: "curl --request POST --header 'Content-Type: application/xml' --data '<key>value</key>' http://example.com"
replace: "curl --request POST --header 'Content-Type: application/xml' --data '<key>value</key>' {{protocol}}://{{curlform.URL}}"

- trigger: ":curljson:"
replace: 'curl --request POST --header ''Content-Type: application/json'' --data ''{"key":"value"}'' http://example.com'
replace: 'curl --request POST --header ''Content-Type: application/json'' --data ''{"key":"value"}'' {{protocol}}://{{curlform.URL}}'

- trigger: ":curlheader:"
replace: "curl --request GET --header 'X-My-Header: 123' http://example.com"
replace: "curl --request GET --header 'X-My-Header: 123' {{protocol}}://{{curlform.URL}}"

- trigger: ":curlcookie:"
replace: "curl --request GET --cookie 'key=value' http://example.com"
replace: "curl --request GET --cookie 'key=value' {{protocol}}://{{curlform.URL}}"

- trigger: ":curlbasic:"
replace: "curl --request GET --user 'username:password' http://example.com"
replace: "curl --request GET --user 'username:password' {{protocol}}://{{curlform.URL}}"

- trigger: ":curlbearer:"
replace: "curl --request GET --header 'Authorization: Bearer token' http://example.com"
replace: "curl --request GET --header 'Authorization: Bearer token' {{protocol}}://{{curlform.URL}}"

- trigger: ":curlproxy:"
replace: "curl --request GET --proxy http://proxy.example.com:8080 http://example.com"
replace: "curl --request GET --proxy http://proxy.example.com:8080 {{protocol}}://{{curlform.URL}}"

- trigger: ":curldownload:"
replace: "curl --request GET --output file.txt http://example.com"
replace: "curl --request GET --output file.txt {{protocol}}://{{curlform.URL}}"

- trigger: ":curlupload:"
replace: "curl --request POST --form 'file=@/path/to/file' http://example.com"
replace: "curl --request POST --form 'file=@/path/to/file' {{protocol}}://{{curlform.URL}}"

0 comments on commit 7a35003

Please sign in to comment.