-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #700 from Badgerati/develop
v2.1.1
- Loading branch information
Showing
24 changed files
with
313 additions
and
42 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
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
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,49 @@ | ||
# Cookies | ||
|
||
In Pode you can add/retrieve cookies for the Request/Response of the current web event. Using the cookie functions has to be done within the context of a web event, such as in Routes/Middleware/Authentication/Logging/Endware. | ||
|
||
## Adding Cookies | ||
|
||
You can add a cookie to the response by using [`Set-PodeCookie`](../../Functions/Cookies/Set-PodeCookie), passing the Name and Value of cookie: | ||
|
||
```powershell | ||
Add-PodeRoute -Method Get -Path '/' -ScriptBlock { | ||
Set-PodeCookie -Name Cookie1 -Value Value1 | ||
} | ||
``` | ||
|
||
You can set a duration for the cookie, in seconds, using `-Duration`, or as an explicit expiry date using `-ExpiryDate`. For example, to set a cookie to expire after 1 minute: | ||
|
||
```powershell | ||
Add-PodeRoute -Method Get -Path '/' -ScriptBlock { | ||
Set-PodeCookie -Name Cookie1 -Value Value1 -Duration 60 | ||
} | ||
``` | ||
|
||
## Getting Cookies | ||
|
||
To retrieve the value of a cookie on the request, you can use [`Get-PodeCookie`](../../Functions/Cookies/Get-PodeCookie): | ||
|
||
```powershell | ||
Add-PodeRoute -Method Get -Path '/' -ScriptBlock { | ||
Get-PodeCookie -Name 'CookieName' | ||
} | ||
``` | ||
|
||
## Removing Cookies | ||
|
||
To flag a cookie for removal on the user's browser you can use [`Remove-PodeCookie`](../../Functions/Cookies/Remove-PodeCookie), which force the cookie to expire: | ||
|
||
```powershell | ||
Add-PodeRoute -Method Get -Path '/' -ScriptBlock { | ||
Remove-PodeCookie -Name 'CookieName' | ||
} | ||
``` | ||
|
||
## Signing Cookies | ||
|
||
You can sign a cookie by supplying a `-Secret` to any of the cookie functions; supplying it to [`Get-PodeCookie`](../../Functions/Cookies/Get-PodeCookie) will attempt to unsign the cookie for the raw value. | ||
|
||
## Expiry Dates | ||
|
||
To update the expiry of a cookie, you can set a duration, in seconds, or as an explicit expiry date using [`Update-PodeCookieExpiry`](../../Functions/Cookies/Update-PodeCookieExpiry). |
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,41 @@ | ||
# Headers | ||
|
||
In Pode you can add/retrieve headers for the Request/Response of the current web event. Using the header functions has to be done within the context of a web event, such as in Routes/Middleware/Authentication/Logging/Endware. | ||
|
||
## Setting Headers | ||
|
||
There are 2 ways of setting headers on a response: [`Add-PodeHeader`](../../Functions/Headers/Add-PodeHeader) and [`Set-PodeHeader`](../../Functions/Headers/Set-PodeHeader). | ||
|
||
[`Add-PodeHeader`](../../Functions/Headers/Add-PodeHeader) will append multiple values for one header on the response - such as the `Set-Cookie` header of which there can be multiple of on a response. The following will add 2 of the same header on the response: | ||
|
||
```powershell | ||
Add-PodeMiddleware -Name Example -ScriptBlock { | ||
Add-PodeHeader -Name Name1 -Value Value1 | ||
Add-PodeHeader -Name Name1 -Value Value2 | ||
} | ||
``` | ||
|
||
[`Set-PodeHeader`](../../Functions/Headers/Set-PodeHeader) will clear all current values for a header on the response, and reset it to one value. The following will add 2 of the same header to the response, but then override that to 1 header: | ||
|
||
```powershell | ||
Add-PodeMiddleware -Name Example -ScriptBlock { | ||
Add-PodeHeader -Name Name1 -Value Value1 | ||
Add-PodeHeader -Name Name1 -Value Value2 | ||
Set-PodeHeader -Name Name1 -Value Value3 | ||
} | ||
``` | ||
|
||
## Getting Headers | ||
|
||
To retrieve the value of a header on the request, you can use [`Get-PodeHeader`](../../Functions/Headers/Get-PodeHeader): | ||
|
||
```powershell | ||
Add-PodeRoute -Method Get -Path '/' -ScriptBlock { | ||
Get-PodeHeader -Name 'X-Header-Name' | ||
} | ||
``` | ||
|
||
## Signing Headers | ||
|
||
You can sign a header by supplying a `-Secret` to any of the header functions; supplying it to [`Get-PodeHeader`](../../Functions/Headers/Get-PodeHeader) will attempt to unsign the header for the raw value. |
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
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
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 @@ | ||
Hello there. |
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
Oops, something went wrong.