Skip to content

Commit

Permalink
Support for .rest file extension
Browse files Browse the repository at this point in the history
Fixes #32
[release]
  • Loading branch information
madskristensen committed Aug 30, 2022
1 parent d77704b commit 9b648ab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ REST Client allows you to send HTTP request and view the response in Visual Stud
![Screenshot](art/screenshot.png)

## The .http file
Any files with the extension `.http` is the entry point to creating HTTP requests.
Any files with the extension `.http` or `.rest` is the entry point to creating HTTP requests.

Here's an example of how to define the requests with variables and code comments.

Expand Down
6 changes: 4 additions & 2 deletions src/RestClientVS/Editor/LanguageFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ namespace RestClientVS
public class LanguageFactory : LanguageBase
{
public const string LanguageName = "Rest";
public const string FileExtension = ".http";
public const string HttpFileExtension = ".http";
public const string RestFileExtension = ".rest";

private DropdownBars _dropdownBars;

public LanguageFactory(object site) : base(site)
Expand All @@ -23,7 +25,7 @@ public void RegisterLanguageService(Package package)

public override string Name => LanguageName;

public override string[] FileExtensions => new[] { FileExtension };
public override string[] FileExtensions => new[] { HttpFileExtension, RestFileExtension };

public override void SetDefaultPreferences(LanguagePreferences preferences)
{
Expand Down
9 changes: 6 additions & 3 deletions src/RestClientVS/RestClientVSPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ namespace RestClientVS
[Guid(PackageGuids.RestClientVSString)]

[ProvideLanguageService(typeof(LanguageFactory), LanguageFactory.LanguageName, 0, ShowHotURLs = false, DefaultToNonHotURLs = true)]
[ProvideLanguageExtension(typeof(LanguageFactory), LanguageFactory.FileExtension)]
[ProvideLanguageExtension(typeof(LanguageFactory), LanguageFactory.HttpFileExtension)]
[ProvideLanguageExtension(typeof(LanguageFactory), LanguageFactory.RestFileExtension)]
[ProvideLanguageEditorOptionPage(typeof(OptionsProvider.GeneralOptions), LanguageFactory.LanguageName, null, "Advanced", null, new[] { "http", "rest", "timeout" })]

[ProvideEditorFactory(typeof(LanguageFactory), 351, CommonPhysicalViewAttributes = (int)__VSPHYSICALVIEWATTRIBUTES.PVA_SupportsPreview, TrustLevel = __VSEDITORTRUSTLEVEL.ETL_AlwaysTrusted)]
[ProvideEditorExtension(typeof(LanguageFactory), LanguageFactory.FileExtension, 65535, NameResourceID = 351)]
[ProvideEditorExtension(typeof(LanguageFactory), LanguageFactory.HttpFileExtension, 65535, NameResourceID = 351)]
[ProvideEditorExtension(typeof(LanguageFactory), LanguageFactory.RestFileExtension, 65535, NameResourceID = 351)]
[ProvideEditorLogicalView(typeof(LanguageFactory), VSConstants.LOGVIEWID.TextView_string, IsTrusted = true)]

[ProvideFileIcon(LanguageFactory.FileExtension, "KnownMonikers.WebScript")]
[ProvideFileIcon(LanguageFactory.HttpFileExtension, "KnownMonikers.WebScript")]
[ProvideFileIcon(LanguageFactory.RestFileExtension, "KnownMonikers.WebScript")]
public sealed class RestClientVSPackage : ToolkitPackage
{
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
Expand Down

0 comments on commit 9b648ab

Please sign in to comment.