로직구현을 아주 심플하게 할 수 있는 웹 서비스 프레임웍으로는 무엇이 있을가요? flask? rails? powreshell로 rest 서비스 로직을 구현할 수 있다면 어떨까요? powershell로 된 pode server는 로직 구현이 아주 심플하다는 데서 주목받고 있습니다. 이번 포스트에서는 goormide에서 pode서버를 구현해 보았습니다.
goormide에서 ubuntu 18.04를 사용하기 위해 기본적인 empty project를 선택해서 컨테이너를 생성합니다.
pwsh 7 설치
# Download the Microsoft repository GPG keys
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb
# Update the list of products
sudo apt-get update
# Enable the "universe" repositories
sudo add-apt-repository universe
# Install PowerShell
sudo apt-get install -y powershell
# Start PowerShell
pwsh
Pode 모듈 설치
https://github.com/Badgerati/Pode
Install-Module -Name Pode
PS /root> import-module pode
PS /root> gcm -module pode
사용할 수 있는 커맨드는 이렇게 많습니다.
CommandType Name Version Source
----------- ---- ------- ------
Function Add-PodeAccessRule 1.8.2 Pode
Function Add-PodeAuth 1.8.2 Pode
Function Add-PodeAuthIIS 1.8.2 Pode
Function Add-PodeAuthUserFile 1.8.2 Pode
Function Add-PodeAuthWindowsAd 1.8.2 Pode
Function Add-PodeEndpoint 1.8.2 Pode
Function Add-PodeEndware 1.8.2 Pode
Function Add-PodeFlashMessage 1.8.2 Pode
Function Add-PodeHandler 1.8.2 Pode
Function Add-PodeHeader 1.8.2 Pode
Function Add-PodeLimitRule 1.8.2 Pode
Function Add-PodeLogger 1.8.2 Pode
Function Add-PodeMiddleware 1.8.2 Pode
Function Add-PodeOAComponentParameter 1.8.2 Pode
Function Add-PodeOAComponentRequestBody 1.8.2 Pode
Function Add-PodeOAComponentResponse 1.8.2 Pode
Function Add-PodeOAComponentSchema 1.8.2 Pode
Function Add-PodeOAResponse 1.8.2 Pode
Function Add-PodePage 1.8.2 Pode
Function Add-PodePage 1.8.2 Pode
Function Add-PodeRoute 1.8.2 Pode
Function Add-PodeSchedule 1.8.2 Pode
Function Add-PodeStaticRoute 1.8.2 Pode
Function Add-PodeTimer 1.8.2 Pode
Function Clear-PodeFlashMessages 1.8.2 Pode
Function Clear-PodeHandlers 1.8.2 Pode
Function Clear-PodeLoggers 1.8.2 Pode
Function Clear-PodeMiddleware 1.8.2 Pode
Function Clear-PodeRoutes 1.8.2 Pode
Function Clear-PodeStaticRoutes 1.8.2 Pode
Function Clear-PodeTimers 1.8.2 Pode
Function Close-PodeDisposable 1.8.2 Pode
Function Close-PodeServer 1.8.2 Pode
Function ConvertTo-PodeOAParameter 1.8.2 Pode
Function ConvertTo-PodeRoute 1.8.2 Pode
Function Disable-PodeErrorLogging 1.8.2 Pode
Function Disable-PodeRequestLogging 1.8.2 Pode
Function Edit-PodeSchedule 1.8.2 Pode
Function Edit-PodeTimer 1.8.2 Pode
Function Enable-PodeCsrfMiddleware 1.8.2 Pode
Function Enable-PodeErrorLogging 1.8.2 Pode
Function Enable-PodeOpenApi 1.8.2 Pode
Function Enable-PodeOpenApiViewer 1.8.2 Pode
Function Enable-PodeRequestLogging 1.8.2 Pode
Function Enable-PodeSessionMiddleware 1.8.2 Pode
Function Get-PodeAuthMiddleware 1.8.2 Pode
Function Get-PodeConfig 1.8.2 Pode
Function Get-PodeCookie 1.8.2 Pode
Function Get-PodeCookieSecret 1.8.2 Pode
Function Get-PodeCsrfMiddleware 1.8.2 Pode
Function Get-PodeEndpoint 1.8.2 Pode
Function Get-PodeFlashMessage 1.8.2 Pode
Function Get-PodeFlashMessageNames 1.8.2 Pode
Function Get-PodeHeader 1.8.2 Pode
Function Get-PodeOpenApiDefinition 1.8.2 Pode
Function Get-PodeRoute 1.8.2 Pode
Function Get-PodeSchedule 1.8.2 Pode
Function Get-PodeScheduleNextTrigger 1.8.2 Pode
Function Get-PodeServerPath 1.8.2 Pode
Function Get-PodeServerRequestMetric 1.8.2 Pode
Function Get-PodeServerRestartCount 1.8.2 Pode
Function Get-PodeServerUptime 1.8.2 Pode
Function Get-PodeSessionId 1.8.2 Pode
Function Get-PodeState 1.8.2 Pode
Function Get-PodeStaticRoute 1.8.2 Pode
Function Get-PodeTimer 1.8.2 Pode
Function Import-PodeModule 1.8.2 Pode
Function Import-PodeSnapIn 1.8.2 Pode
Function Initialize-PodeCsrf 1.8.2 Pode
Function Invoke-PodeSchedule 1.8.2 Pode
Function Invoke-PodeScriptBlock 1.8.2 Pode
Function Invoke-PodeTimer 1.8.2 Pode
Function Lock-PodeObject 1.8.2 Pode
Function Move-PodeResponseUrl 1.8.2 Pode
Function New-PodeAuthType 1.8.2 Pode
Function New-PodeCsrfToken 1.8.2 Pode
Function New-PodeLoggingMethod 1.8.2 Pode
Function New-PodeOABoolProperty 1.8.2 Pode
Function New-PodeOAIntProperty 1.8.2 Pode
Function New-PodeOANumberProperty 1.8.2 Pode
Function New-PodeOAObjectProperty 1.8.2 Pode
Function New-PodeOARequestBody 1.8.2 Pode
Function New-PodeOAStringProperty 1.8.2 Pode
Function Out-PodeHost 1.8.2 Pode
Function Pode 1.8.2 Pode
Function Protect-PodeLogItem 1.8.2 Pode
Function Protect-PodeValue 1.8.2 Pode
Function Read-PodeTcpClient 1.8.2 Pode
Function Remove-PodeAuth 1.8.2 Pode
Function Remove-PodeCookie 1.8.2 Pode
Function Remove-PodeFlashMessage 1.8.2 Pode
Function Remove-PodeHandler 1.8.2 Pode
Function Remove-PodeLogger 1.8.2 Pode
Function Remove-PodeMiddleware 1.8.2 Pode
Function Remove-PodeRoute 1.8.2 Pode
Function Remove-PodeSchedule 1.8.2 Pode
Function Remove-PodeSession 1.8.2 Pode
Function Remove-PodeState 1.8.2 Pode
Function Remove-PodeStaticRoute 1.8.2 Pode
Function Remove-PodeTimer 1.8.2 Pode
Function Resolve-PodeValue 1.8.2 Pode
Function Restore-PodeState 1.8.2 Pode
Function Save-PodeRequestFile 1.8.2 Pode
Function Save-PodeSession 1.8.2 Pode
Function Save-PodeState 1.8.2 Pode
Function Send-PodeSignal 1.8.2 Pode
Function Set-PodeCookie 1.8.2 Pode
Function Set-PodeCookieSecret 1.8.2 Pode
Function Set-PodeHeader 1.8.2 Pode
Function Set-PodeOAAuth 1.8.2 Pode
Function Set-PodeOAGlobalAuth 1.8.2 Pode
Function Set-PodeOARequest 1.8.2 Pode
Function Set-PodeOARouteInfo 1.8.2 Pode
Function Set-PodeResponseAttachment 1.8.2 Pode
Function Set-PodeResponseStatus 1.8.2 Pode
Function Set-PodeScheduleConcurrency 1.8.2 Pode
Function Set-PodeState 1.8.2 Pode
Function Set-PodeViewEngine 1.8.2 Pode
Function Show-PodeGui 1.8.2 Pode
Function Start-PodeServer 1.8.2 Pode
Function Start-PodeStaticServer 1.8.2 Pode
Function Start-PodeStopwatch 1.8.2 Pode
Function Test-IsEmpty 1.8.2 Pode
Function Test-IsPSCore 1.8.2 Pode
Function Test-IsUnix 1.8.2 Pode
Function Test-IsWindows 1.8.2 Pode
Function Test-PodeCookie 1.8.2 Pode
Function Test-PodeCookieSigned 1.8.2 Pode
Function Test-PodeFlashMessage 1.8.2 Pode
Function Test-PodeHeader 1.8.2 Pode
Function Test-PodeHeaderSigned 1.8.2 Pode
Function Test-PodeIsHeroku 1.8.2 Pode
Function Test-PodeIsIIS 1.8.2 Pode
Function Test-PodeState 1.8.2 Pode
Function Update-PodeCookieExpiry 1.8.2 Pode
Function Use-PodePartialView 1.8.2 Pode
Function Use-PodeScript 1.8.2 Pode
Function Use-PodeStream 1.8.2 Pode
Function Wait-PodeTask 1.8.2 Pode
Function Write-PodeCsvResponse 1.8.2 Pode
Function Write-PodeErrorLog 1.8.2 Pode
Function Write-PodeFileResponse 1.8.2 Pode
Function Write-PodeHost 1.8.2 Pode
Function Write-PodeHtmlResponse 1.8.2 Pode
Function Write-PodeJsonResponse 1.8.2 Pode
Function Write-PodeLog 1.8.2 Pode
Function Write-PodeMarkdownResponse 1.8.2 Pode
Function Write-PodeTcpClient 1.8.2 Pode
Function Write-PodeTextResponse 1.8.2 Pode
Function Write-PodeViewResponse 1.8.2 Pode
Function Write-PodeXmlResponse 1.8.2 Pode
PS /root>
실행 예제
Start-PodeServer {
Add-PodeEndpoint -Address 0.0.0.0 -Port 80 -Protocol Http
Add-PodeRoute -Method Get -Path '/ping' -ScriptBlock {
Write-PodeJsonResponse -Value @{ 'value' = 'pong' }
}
}
다음은 실행한 모습입니다.
goormide의 오른쪽 아래를 보면 modal box처럼 조그만 웹브라우징을 할 수 있는 화면이 나오는 버튼이 있어서 이를 이용해 봤습니다.
이상으로 pode서버의 기본을 알아보았습니다. pode 서버는 생각보다 심플하게 로직을 구성할 수 있기 때문에, developer보다는 system engineer쪽에서 좀 더 활발히 다루어지고 있는 느낌입니다만, 성정은 멈추지 않고 있어 기대가 됩니다.
다음에는 다음과 같은 예제도 재밌겠다고 생각하고 있습니다.
- DB(sqlite)와 결합해서
- react와 결합해서 ajax로
- reverse proxy(nginx)와 함께
- kubernetes pod로 deploy해서
- 등등