jpsider / RestPS

Simple ReST Framework for Powershell
MIT License
114 stars 31 forks source link

Add plain text response #50

Closed robinmalik closed 4 years ago

robinmalik commented 4 years ago

Modification for Issue #49

I noticed you've used quite a few script scoped variables which makes it a bit easier to 'pass' data around, so I went with that approach. Here's an example route for a plain text reply from our server:

  {
    "RequestType": "POST",
    "RequestURL": "/",
    "RequestCommand": "C:/RestPS/endpoints/POST/Return-Token.ps1",
    "ResponseContentType": "text/plain"
  }

Invoke-RequestRouter will attempt to grab a value for ResponseContentType for the route. If it's $null, then Invoke-StreamOutput will default to a content type of application/json and convert the data to JSON format for the return. Otherwise it's set to whatever the user has specified for the route and currently, returns the data as plain text.

jpsider commented 4 years ago

Tests are failing because I have not migrated to Pester 5. So I either need to spend some time to migrate or figure out how to tell AppVeyor to use an older version.

jpsider commented 4 years ago

I merged the changes, but that will not deploy the new version yet. This will just run through the build process, if it passes, then I can deploy it out to the gallery.