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

New WebRoute

Tyler James Leonhardt edited this page Nov 11, 2017 · 2 revisions

NAME

New-WebRoute

SYNOPSIS

Adds a new HTTP Route

SYNTAX

New-WebRoute [[-Path] <Object>] [[-Method] <Object>] [[-ScriptBlock] <Object>] [[-ScriptPath] <Object>] [<CommonParameters>]

DESCRIPTION

This cmdlet defines an HTTP route that your server will listen for.

PARAMETERS

  • Path: The HTTP Route/Path/endpoint that you call to trigger this script
  • Method: The HTTP Verb/Method for this request
  • ScriptBlock: A script block that will be triggered when this HTTP Route/Path/endpoint has been called
  • ScriptPath: A path to a script that will be triggered when this HTTP Route/Path/endpoint has been called
  • CommonParameters

EXAMPLE

# Using a script block
New-WebRoute -Path "/helloworld" -Method "GET" -ScriptBlock {
    $response.Send('Hello World');
}

# Using a script path
New-WebRoute -Path "/helloworld" -Method "GET" -ScriptPath ./example.ps1
Clone this wiki locally