-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib: add basic_authentication method to HTTP extension
This convenience method allows users to directly add basic auth to an existing constructed request map without needing to use a wither pattern. Also update the wither pattern example to correctly reflect the actions that need to be done if using that approach.
- Loading branch information
Showing
3 changed files
with
120 additions
and
5 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,22 @@ | ||
mito -use http src.cel | ||
! stderr . | ||
cmp stdout want.txt | ||
|
||
-- src.cel -- | ||
request("GET", "http://www.example.com/").basic_authentication("username", "password") | ||
-- want.txt -- | ||
{ | ||
"Close": false, | ||
"ContentLength": 0, | ||
"Header": { | ||
"Authorization": [ | ||
"Basic dXNlcm5hbWU6cGFzc3dvcmQ=" | ||
] | ||
}, | ||
"Host": "www.example.com", | ||
"Method": "GET", | ||
"Proto": "HTTP/1.1", | ||
"ProtoMajor": 1, | ||
"ProtoMinor": 1, | ||
"URL": "http://www.example.com/" | ||
} |
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