Skip to content
This repository was archived by the owner on Dec 8, 2021. It is now read-only.
This repository was archived by the owner on Dec 8, 2021. It is now read-only.

[Question] how do I force the code to end the request before the end of the routine is reached? #195

@loomanss

Description

@loomanss

i was assuming that if i use $response.send() the request is closed and the response is sent to the client. however, the code will continue to run. The result is that the last $ response.send is displayed as a result on the client side. how do I force the code to end the request before the end of the routine is reached?

my work-around at this moment :

Import-Module -Name Polaris
$global:PolarisRestPort = 8183
$global:AppName = "Polaris-Test"

    $app = Start-Polaris -Port $global:PolarisRestPort -MinRunspaces 1  -MaxRunspaces  5   # all params are optional

    $functionMiddleWare = {
        $authkey = $Request.Headers['Authorization']
        if($authkey -eq $null)
        { 
            $Response.SetStatusCode(401)
            $Response.Send("not authorized")
            [Polaris]::Send($Response)
            }}
    New-PolarisRouteMiddleware -Name MyParser -Polaris $app  -Scriptblock $functionMiddleWare
    $functionHello = { $Response.Send("hello")}
    New-PolarisRoute -method GET -Path '/hello' -Polaris $app  -Scriptblock $functionHello
    while($app.Listener.IsListening){Wait-Event callbackcomplete}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions