moved respond text html nad json
This commit is contained in:
@@ -958,6 +958,41 @@ $script
|
||||
|
||||
#endregion UIHtml
|
||||
|
||||
#region Handler Stubs
|
||||
|
||||
function Respond-Text {
|
||||
param($Context, $Text)
|
||||
$bytes = [Text.Encoding]::UTF8.GetBytes($Text)
|
||||
$Context.Response.ContentType = 'text/plain'
|
||||
$Context.Response.ContentLength64 = $bytes.Length
|
||||
$Context.Response.OutputStream.Write($bytes,0,$bytes.Length)
|
||||
$Context.Response.OutputStream.Close()
|
||||
}
|
||||
|
||||
function Respond-HTML {
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][object] $Context,
|
||||
[Parameter(Mandatory = $true)][string] $Html
|
||||
)
|
||||
$bytes = [Text.Encoding]::UTF8.GetBytes($Html)
|
||||
$Context.Response.ContentType = 'text/html'
|
||||
$Context.Response.ContentLength64 = $bytes.Length
|
||||
$Context.Response.OutputStream.Write($bytes, 0, $bytes.Length)
|
||||
$Context.Response.OutputStream.Close()
|
||||
}
|
||||
|
||||
# new helper to return JSON
|
||||
function Respond-JSON {
|
||||
param($Context, $Object)
|
||||
$json = $Object | ConvertTo-Json -Depth 5
|
||||
$bytes = [Text.Encoding]::UTF8.GetBytes($json)
|
||||
$Context.Response.ContentType = 'application/json'
|
||||
$Context.Response.ContentLength64 = $bytes.Length
|
||||
$Context.Response.OutputStream.Write($bytes,0,$bytes.Length)
|
||||
$Context.Response.OutputStream.Close()
|
||||
}
|
||||
|
||||
# Sends the HTML for a given page or invokes a task handler
|
||||
function Dispatch-Request {
|
||||
param($Context)
|
||||
@@ -1173,40 +1208,7 @@ $script
|
||||
Write-LogHybrid "Launching UI" Info Startup
|
||||
|
||||
|
||||
#region Handler Stubs
|
||||
|
||||
function Respond-Text {
|
||||
param($Context, $Text)
|
||||
$bytes = [Text.Encoding]::UTF8.GetBytes($Text)
|
||||
$Context.Response.ContentType = 'text/plain'
|
||||
$Context.Response.ContentLength64 = $bytes.Length
|
||||
$Context.Response.OutputStream.Write($bytes,0,$bytes.Length)
|
||||
$Context.Response.OutputStream.Close()
|
||||
}
|
||||
|
||||
function Respond-HTML {
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][object] $Context,
|
||||
[Parameter(Mandatory = $true)][string] $Html
|
||||
)
|
||||
$bytes = [Text.Encoding]::UTF8.GetBytes($Html)
|
||||
$Context.Response.ContentType = 'text/html'
|
||||
$Context.Response.ContentLength64 = $bytes.Length
|
||||
$Context.Response.OutputStream.Write($bytes, 0, $bytes.Length)
|
||||
$Context.Response.OutputStream.Close()
|
||||
}
|
||||
|
||||
# new helper to return JSON
|
||||
function Respond-JSON {
|
||||
param($Context, $Object)
|
||||
$json = $Object | ConvertTo-Json -Depth 5
|
||||
$bytes = [Text.Encoding]::UTF8.GetBytes($json)
|
||||
$Context.Response.ContentType = 'application/json'
|
||||
$Context.Response.ContentLength64 = $bytes.Length
|
||||
$Context.Response.OutputStream.Write($bytes,0,$bytes.Length)
|
||||
$Context.Response.OutputStream.Close()
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region Install-DattoRMM-Helper
|
||||
|
||||
Reference in New Issue
Block a user