Closed GHRoss closed 2 months ago
You can find one here. It's not yet committed because it's part of https://github.com/Badgerati/Pode/pull/1333 https://github.com/Badgerati/Pode/blob/f16cc3a61a502485f3f2713b4c0aafd4d618def6/examples/WebHook.ps1
You can find one here. It's not yet committed because it's part of #1333 https://github.com/Badgerati/Pode/blob/f16cc3a61a502485f3f2713b4c0aafd4d618def6/examples/WebHook.ps1
Wow! What a happy coincidence! What would be the best way to add simple auth to this?
Also, would the best place to do the actual storing of the data be on line 141?
the easy way is to save on the file system using Save-PodeState -Path './state.json'
on line 114
$state:subscriptions.Remove($data.url)
# Saving to ./state.json
Save-PodeState -Path './state.json'`
# Respond with a status message
Write-PodeJsonResponse -Value @{ message = 'Unsubscribed successfully!' } -StatusCode 200
and on line 79
$state:subscriptions[$data.url] = $true
# Saving to ./state.json
Save-PodeState -Path './state.json'`
# Respond with a status message
Write-PodeJsonResponse -Value @{ message = 'Subscribed successfully!' }
for the authentication you can grab as example petstore https://github.com/Badgerati/Pode/blob/f16cc3a61a502485f3f2713b4c0aafd4d618def6/examples/PetStore/Petstore-openApi.ps1 Line 129
New-PodeAuthScheme -ApiKey -LocationName 'api_key' | Add-PodeAuth -Name 'api_key' -Sessionless -ScriptBlock {
the easy way is to save on the file system using
Save-PodeState -Path './state.json'
on line 114$state:subscriptions.Remove($data.url) # Saving to ./state.json Save-PodeState -Path './state.json'` # Respond with a status message Write-PodeJsonResponse -Value @{ message = 'Unsubscribed successfully!' } -StatusCode 200
and on line 79
$state:subscriptions[$data.url] = $true # Saving to ./state.json Save-PodeState -Path './state.json'` # Respond with a status message Write-PodeJsonResponse -Value @{ message = 'Subscribed successfully!' }
Interesting! So you wouldn't use the /store endpoint?
Sorry, I was saving the state, not the store.
The store you can save it anywhere you like S3, File, DB, or if you want to use $state:
you can do it too
Sorry, I was saving the state, not the store. The store you can save it anywhere you like S3, File, DB, or if you want to use
$state:
you can do it too
Great, thank you. Just to be clear, best to add to datastore on line 141 as validation would have passed?
This is a sample theoretical; you don't need to print the content of your body. Sure, It can be moved after the validation. Validation is not something that many people use
Thank you!
Is there an example of a webhook server? I'm looking to have an endpoint that accepts anything that's thrown at it with auth in the header that writes the request to a file or database.