Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Conversion to latest webapi.

- Removed settings apis.
- Renamed *Service to *Controller.
- Removed IUserValidator
- Moved all route initialization to NinjectServices.cs.
  • Loading branch information...
commit 9c410354b89541689ae05ecc61bdb44eedf7f959 1 parent 3a72482
@davidfowl davidfowl authored
Showing with 362 additions and 634 deletions.
  1. +6 −0 .nuget/NuGet.Config
  2. BIN  .nuget/NuGet.exe
  3. +36 −9 .nuget/NuGet.targets
  4. +6 −0 .nuget/sources
  5. +3 −3 Kudu.Client/Editor/RemoteProjectSystem.cs
  6. +54 −9 Kudu.Services.Web/App_Start/NinjectServices.cs
  7. +0 −1  Kudu.Services.Web/Global.asax
  8. +0 −135 Kudu.Services.Web/Global.asax.cs
  9. +7 −5 Kudu.Services.Web/Infrastruture/HttpHandlerRouteHandler.cs
  10. +18 −44 Kudu.Services.Web/Kudu.Services.Web.csproj
  11. +66 −0 Kudu.Services.Web/Services/NinjectWebApiDependencyResolver.cs
  12. +0 −12 Kudu.Services.Web/Services/SimpleUserValidator.cs
  13. +0 −27 Kudu.Services.Web/Tracing/TraceErrorHandler.cs
  14. +8 −3 Kudu.Services.Web/Web.config
  15. +5 −7 Kudu.Services.Web/packages.config
  16. +0 −43 Kudu.Services/Authorization/BasicAuthorizeHandler.cs
  17. +0 −8 Kudu.Services/Authorization/IUserValidator.cs
  18. +0 −32 Kudu.Services/Commands/CommandService.cs
  19. +0 −12 Kudu.Services/Commands/CommandStatusHandler.cs
  20. +48 −53 Kudu.Services/Deployment/{DeploymentService.cs → DeploymentController.cs}
  21. +6 −8 Kudu.Services/Diagnostics/{DiagnosticsService.cs → DiagnosticsController.cs}
  22. +46 −0 Kudu.Services/Editor/FilesController.cs
  23. +0 −51 Kudu.Services/Editor/FilesService.cs
  24. +17 −23 Kudu.Services/GitServer/{InfoRefsService.cs → InfoRefsController.cs}
  25. +2 −2 Kudu.Services/GitServer/{ReceivePackService.cs → ReceivePackHandler.cs}
  26. +3 −13 Kudu.Services/GitServer/{RpcService.cs → RpcController.cs}
  27. +1 −1  Kudu.Services/Infrastructure/LockExtensions.cs
  28. +21 −41 Kudu.Services/Kudu.Services.csproj
  29. +0 −40 Kudu.Services/Settings/AppSettingsService.cs
  30. +0 −40 Kudu.Services/Settings/ConnectionStringsService.cs
  31. +5 −8 Kudu.Services/SourceControl/{DeploymentSourceControlService.cs → LiveScmController.cs}
  32. +4 −4 Kudu.Services/packages.config
View
6 .nuget/NuGet.Config
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <solution>
+ <add key="disableSourceControlIntegration" value="true" />
+ </solution>
+</configuration>
View
BIN  .nuget/NuGet.exe
Binary file not shown
View
45 .nuget/NuGet.targets
@@ -2,14 +2,34 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
+ </PropertyGroup>
+
+ <PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
+ <!-- Windows specific commands -->
+ <NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
+ <PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
+ <PackagesDir>$([System.IO.Path]::Combine($(SolutionDir), "packages"))</PackagesDir>
+ </PropertyGroup>
+
+ <PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
+ <!-- We need to launch nuget.exe with the mono command if we're not on windows -->
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
- <NuGetExePath>$(NuGetToolsPath)\nuget.exe</NuGetExePath>
- <PackagesConfig>$(ProjectDir)packages.config</PackagesConfig>
+ <PackagesConfig>packages.config</PackagesConfig>
<PackagesDir>$(SolutionDir)packages</PackagesDir>
+ </PropertyGroup>
+
+ <Import Project="$(NuGetToolsPath)\sources" />
+
+ <PropertyGroup>
+ <!-- NuGet command -->
+ <NuGetExePath>$(NuGetToolsPath)\nuget.exe</NuGetExePath>
+ <NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
+ <NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>
+
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
<!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config -->
- <PackageSources>""</PackageSources>
+ <PackageSources Condition="$(PackageSources) == ''">""</PackageSources>
<!-- Enable the restore command to run before builds -->
<RestorePackages Condition="$(RestorePackages) == ''">false</RestorePackages>
@@ -18,8 +38,8 @@
<BuildPackage Condition="$(BuildPackage) == ''">false</BuildPackage>
<!-- Commands -->
- <RestoreCommand>"$(NuGetExePath)" install "$(PackagesConfig)" -source $(PackageSources) -o "$(PackagesDir)"</RestoreCommand>
- <BuildCommand>"$(NuGetExePath)" pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)"</BuildCommand>
+ <RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source $(PackageSources) -o "$(PackagesDir)"</RestoreCommand>
+ <BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand>
<!-- Make the build depend on restore packages -->
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
@@ -33,20 +53,27 @@
BuildPackage;
</BuildDependsOn>
</PropertyGroup>
-
+
<Target Name="CheckPrerequisites">
<!-- Raise an error if we're unable to locate nuget.exe -->
<Error Condition="!Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
</Target>
-
+
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(RestoreCommand)"
+ Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
+
+ <Exec Command="$(RestoreCommand)"
LogStandardErrorAsError="true"
- Condition="Exists('$(PackagesConfig)')" />
+ Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
</Target>
<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
+ <Exec Command="$(BuildCommand)"
+ Condition=" '$(OS)' != 'Windows_NT' " />
+
<Exec Command="$(BuildCommand)"
- LogStandardErrorAsError="true" />
+ LogStandardErrorAsError="true"
+ Condition=" '$(OS)' == 'Windows_NT' " />
</Target>
</Project>
View
6 .nuget/sources
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <PackageSources>"http://www.myget.org/F/aspnetwebstacknightly/;https://nuget.org/api/v2/"</PackageSources>
+ </PropertyGroup>
+</Project>
View
6 Kudu.Client/Editor/RemoteProjectSystem.cs
@@ -16,7 +16,7 @@ public string ReadAllText(string path)
{
// REVIEW: Do we need to url encode?
// REVIEW: this goes through the same client that set the Accept header to application/json, but we receive text/plain
- return _client.GetAsync("?path=" + path)
+ return _client.GetAsync(path)
.Result
.EnsureSuccessStatusCode()
.Content
@@ -31,14 +31,14 @@ public Project GetProject()
public void WriteAllText(string path, string content)
{
- _client.PostAsync("save", HttpClientHelper.CreateJsonContent(new KeyValuePair<string, string>("path", path), new KeyValuePair<string, string>("content", content)))
+ _client.PutAsync(path, HttpClientHelper.CreateJsonContent(new KeyValuePair<string, string>("content", content)))
.Result
.EnsureSuccessStatusCode();
}
public void Delete(string path)
{
- _client.PostAsync("delete", HttpClientHelper.CreateJsonContent(new KeyValuePair<string, string>("path", path)))
+ _client.DeleteAsync(path)
.Result
.EnsureSuccessStatusCode();
}
View
63 Kudu.Services.Web/App_Start/NinjectServices.cs
@@ -11,15 +11,19 @@
using Kudu.Core.SourceControl;
using Kudu.Core.SourceControl.Git;
using Kudu.Core.Tracing;
-using Kudu.Services.Authorization;
using Kudu.Services.Performance;
using Kudu.Services.Web.Services;
+using Kudu.Services.Web.Infrastruture;
using Kudu.Services.Web.Tracing;
using Microsoft.Web.Infrastructure.DynamicModuleHelper;
using Ninject;
using Ninject.Activation;
-using Ninject.Extensions.Wcf;
using XmlSettings;
+using System.Web.Routing;
+using Kudu.Services.GitServer;
+using System.Web.Http;
+using System.Net.Http.Formatting;
+using Newtonsoft.Json.Serialization;
[assembly: WebActivator.PreApplicationStartMethod(typeof(Kudu.Services.Web.App_Start.NinjectServices), "Start")]
[assembly: WebActivator.ApplicationShutdownMethodAttribute(typeof(Kudu.Services.Web.App_Start.NinjectServices), "Stop")]
@@ -54,7 +58,6 @@ private static IKernel CreateKernel()
RegisterServices(kernel);
- KernelContainer.Kernel = kernel;
return kernel;
}
@@ -76,7 +79,6 @@ private static void RegisterServices(IKernel kernel)
// General
kernel.Bind<HttpContextBase>().ToMethod(context => new HttpContextWrapper(HttpContext.Current));
kernel.Bind<IEnvironment>().ToConstant(environment);
- kernel.Bind<IUserValidator>().To<SimpleUserValidator>().InSingletonScope();
kernel.Bind<IServerConfiguration>().ToConstant(serverConfiguration);
kernel.Bind<IFileSystem>().To<FileSystem>().InSingletonScope();
kernel.Bind<RepositoryConfiguration>().ToConstant(gitConfiguration);
@@ -122,7 +124,7 @@ private static void RegisterServices(IKernel kernel)
Path.Combine(environment.DeploymentTargetPath, Constants.NpmDebugLogFile),
};
- kernel.Bind<DiagnosticsService>().ToMethod(context => new DiagnosticsService(paths));
+ kernel.Bind<DiagnosticsController>().ToMethod(context => new DiagnosticsController(paths));
// Deployment Service
kernel.Bind<ISettings>().ToMethod(context => new XmlSettings.Settings(GetSettingsPath(environment)));
@@ -132,7 +134,7 @@ private static void RegisterServices(IKernel kernel)
kernel.Bind<ISiteBuilderFactory>().To<SiteBuilderFactory>()
.InRequestScope();
- kernel.Bind<IServerRepository>().ToMethod(context => new GitExeServer(environment.DeploymentRepositoryPath,
+ kernel.Bind<IServerRepository>().ToMethod(context => new GitExeServer(environment.DeploymentRepositoryPath,
initLock,
context.Kernel.Get<IDeploymentEnvironment>(),
context.Kernel.Get<ITraceFactory>()))
@@ -148,15 +150,58 @@ private static void RegisterServices(IKernel kernel)
// Git server
kernel.Bind<IDeploymentEnvironment>().To<DeploymentEnvrionment>();
- kernel.Bind<IGitServer>().ToMethod(context => new GitExeServer(environment.DeploymentRepositoryPath,
- initLock,
- context.Kernel.Get<IDeploymentEnvironment>(),
+ kernel.Bind<IGitServer>().ToMethod(context => new GitExeServer(environment.DeploymentRepositoryPath,
+ initLock,
+ context.Kernel.Get<IDeploymentEnvironment>(),
context.Kernel.Get<ITraceFactory>()))
.InRequestScope();
// Editor
kernel.Bind<IProjectSystem>().ToMethod(context => GetEditorProjectSystem(environment, context))
.InRequestScope();
+
+ RegisterRoutes(kernel, RouteTable.Routes);
+ }
+
+ public static void RegisterRoutes(IKernel kernel, RouteCollection routes)
+ {
+ var configuration = kernel.Get<IServerConfiguration>();
+
+ GlobalConfiguration.Configuration.Formatters.Clear();
+ GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.LocalOnly;
+ var jsonFormatter = new JsonMediaTypeFormatter();
+ GlobalConfiguration.Configuration.Formatters.Add(jsonFormatter);
+ GlobalConfiguration.Configuration.DependencyResolver = new NinjectWebApiDependencyResolver(kernel);
+
+ // Git Service
+ routes.MapHttpRoute("git-info-refs", configuration.GitServerRoot + "/info/refs", new { controller = "InfoRefs", action = "Execute" });
+
+ // Push url
+ routes.MapHandler<ReceivePackHandler>(kernel, "git-receive-pack", configuration.GitServerRoot + "/git-receive-pack");
+
+ // Clone url
+ routes.MapHttpRoute("git-upload-pack", configuration.GitServerRoot + "/git-upload-pack ", new { controller = "Rpc", action = "UploadPack" });
+
+ // Live Scm (deployment repository)
+ routes.MapHttpRoute("scm-info", "live/scm/info", new { controller = "LiveScm", action = "GetRepositoryInfo" });
+ routes.MapHttpRoute("scm-clean", "live/scm/clean", new { controller = "LiveScm", action = "Clean" });
+
+ // Live Files
+ routes.MapHttpRoute("all-files", "live/files", new { controller = "Files", action = "GetFiles" });
+ routes.MapHttpRoute("one-file", "live/files/{*path}", new { controller = "Files", action = "GetFile" }, new { verb = new HttpMethodConstraint("GET") });
+ routes.MapHttpRoute("save-file", "live/files/{*path}", new { controller = "Files", action = "Save" }, new { verb = new HttpMethodConstraint("PUT") });
+ routes.MapHttpRoute("delete-file", "live/files/{*path}", new { controller = "Files", action = "Delete" }, new { verb = new HttpMethodConstraint("DELETE") });
+
+ // Deployments
+ routes.MapHttpRoute("all-deployments", "deployments", new { controller = "Deployment", action = "GetDeployResults" });
+ routes.MapHttpRoute("one-deployment-get", "deployments/{id}", new { controller = "Deployment", action = "GetResult" }, new { verb = new HttpMethodConstraint("GET") });
+ routes.MapHttpRoute("one-deployment-put", "deployments/{id}", new { controller = "Deployment", action = "Deploy" }, new { verb = new HttpMethodConstraint("PUT") });
+ routes.MapHttpRoute("one-deployment-delete", "deployments/{id}", new { controller = "Deployment", action = "Delete" }, new { verb = new HttpMethodConstraint("DELETE") });
+ routes.MapHttpRoute("one-deployment-log", "deployments/{id}/log", new { controller = "Deployment", action = "GetLogEntry" });
+ routes.MapHttpRoute("one-deployment-log-details", "deployments/{id}/log/{logId}", new { controller = "Deployment", action = "GetLogEntryDetails" });
+
+ // Diagnostics
+ routes.MapHttpRoute("diagnostics", "dump", new { controller = "Diagnostics", action = "GetLog" });
}
private static IProjectSystem GetEditorProjectSystem(IEnvironment environment, IContext context)
View
1  Kudu.Services.Web/Global.asax
@@ -1 +0,0 @@
-<%@ Application Codebehind="Global.asax.cs" Inherits="Kudu.Services.MvcApplication" Language="C#" %>
View
135 Kudu.Services.Web/Global.asax.cs
@@ -1,135 +0,0 @@
-using System;
-using System.Net.Http;
-using System.Net.Http.Formatting;
-using System.ServiceModel;
-using System.ServiceModel.Activation;
-using System.Web.Routing;
-using Kudu.Services.Authorization;
-using Kudu.Services.Deployment;
-using Kudu.Services.Documents;
-using Kudu.Services.GitServer;
-using Kudu.Services.Performance;
-using Kudu.Services.Settings;
-using Kudu.Services.SourceControl;
-using Kudu.Services.Web;
-using Kudu.Services.Web.Infrastruture;
-using Kudu.Services.Web.Tracing;
-using Microsoft.ApplicationServer.Http.Activation;
-using Ninject;
-using Ninject.Extensions.Wcf;
-using SignalR.Hosting.AspNet.Routing;
-
-namespace Kudu.Services
-{
- public class MvcApplication : System.Web.HttpApplication
- {
- public static void RegisterRoutes(RouteCollection routes)
- {
- var configuration = KernelContainer.Kernel.Get<IServerConfiguration>();
- var factory = GetFactory();
-
- // routes.MapConnection<LiveCommandStatusHandler>("LiveCommandStatus", "live/command/status/{*operation}");
- // routes.MapConnection<DevCommandStatusHandler>("DevCommandStatus", "dev/command/status/{*operation}");
- routes.MapHandler<ReceivePackService>("git-receive-pack", configuration.GitServerRoot + "/git-receive-pack");
-
- // Source control servers
- // Git
- MapServiceRoute<InfoRefsService>(routes, configuration.GitServerRoot + "/info/refs", factory);
- MapServiceRoute<RpcService>(routes, configuration.GitServerRoot, factory);
-
-
- // Source control interaction
- MapServiceRoute<DeploymentSourceControlService>(routes, "live/scm", factory);
-
- // Deployment
- MapServiceRoute<DeploymentService>(routes, "deployments", factory);
-
- // Files
- // MapServiceRoute<FilesService>("dev/files", factory);
- var liveFilesRoute = MapServiceRoute<FilesService>(routes, "live/files", factory);
- liveFilesRoute.Defaults = new RouteValueDictionary(new { live = true });
-
- // Commands
- // MapServiceRoute<CommandService>("dev/command", factory);
- // var liveCommandRoute = MapServiceRoute<CommandService>("live/command", factory);
- // liveCommandRoute.Defaults = new RouteValueDictionary(new { live = true });
-
- if (AppSettings.SettingsEnabled)
- {
- // Settings
- MapServiceRoute<AppSettingsService>(routes, "appsettings", factory);
- MapServiceRoute<ConnectionStringsService>(routes, "connectionstrings", factory);
- }
-
- MapServiceRoute<DiagnosticsService>(routes, "dump", factory);
- }
-
- private static ServiceRoute MapServiceRoute<T>(RouteCollection routes, string url, HttpServiceHostFactory factory)
- {
- var route = new ServiceRoute(url, factory, typeof(T));
- routes.Add(route);
- return route;
- }
-
- protected void Application_Start()
- {
- RegisterRoutes(RouteTable.Routes);
- }
-
- private static HttpServiceHostFactory GetFactory()
- {
- var factory = new HttpServiceHostFactory();
-
- // REVIEW: Set to max to accomodate large file uploads in initial scm setup.
- factory.Configuration.MaxBufferSize = Int32.MaxValue;
- factory.Configuration.MaxReceivedMessageSize = Int32.MaxValue;
- factory.Configuration.EnableHelpPage = true;
- factory.Configuration.EnableTestClient = true;
- factory.Configuration.TransferMode = TransferMode.Streamed;
-
- factory.Configuration.Formatters.Clear();
- factory.Configuration.Formatters.Add(new JsonValueMediaTypeFormatter());
- factory.Configuration.Formatters.Add(new JsonMediaTypeFormatter());
-
-#if DEBUG
- factory.Configuration.IncludeExceptionDetail = true;
-#endif
- // Set IoC methods
- factory.Configuration.CreateInstance = CreateInstance;
- factory.Configuration.ReleaseInstance = ReleaseInstance;
-
- factory.Configuration.ErrorHandlers = (handlers, service, op) =>
- {
- handlers.Add(KernelContainer.Kernel.Get<TraceErrorHandler>());
- };
-
- // Add the authorization handler on specific services method.
- var existingRequestHandlerFactory = factory.Configuration.RequestHandlers;
- factory.Configuration.RequestHandlers = (c, e, od) =>
- {
- if (existingRequestHandlerFactory != null)
- {
- existingRequestHandlerFactory(c, e, od);
- }
-
- // Enable authentication based on the configuration setting
- if (AppSettings.AuthenticationEnabled)
- {
- c.Insert(0, KernelContainer.Kernel.Get<BasicAuthorizeHandler>());
- }
- };
-
- return factory;
- }
-
- private static object CreateInstance(Type type, InstanceContext context, HttpRequestMessage request)
- {
- return KernelContainer.Kernel.GetService(type);
- }
-
- private static void ReleaseInstance(InstanceContext context, object o)
- {
- KernelContainer.Kernel.Release(o);
- }
- }
-}
View
12 Kudu.Services.Web/Infrastruture/HttpHandlerRouteHandler.cs
@@ -2,29 +2,31 @@
using System.Web;
using System.Web.Routing;
using Ninject;
-using Ninject.Extensions.Wcf;
namespace Kudu.Services.Web.Infrastruture
{
public class HttpHandlerRouteHandler : IRouteHandler
{
private readonly Type _handlerType;
- public HttpHandlerRouteHandler(Type handlerType)
+ private readonly IKernel _kernel;
+
+ public HttpHandlerRouteHandler(IKernel kernel, Type handlerType)
{
+ _kernel = kernel;
_handlerType = handlerType;
}
public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
- return (IHttpHandler)KernelContainer.Kernel.Get(_handlerType);
+ return (IHttpHandler)_kernel.Get(_handlerType);
}
}
public static class HttpHandlerExtensions
{
- public static RouteBase MapHandler<THandler>(this RouteCollection routes, string name, string url)
+ public static RouteBase MapHandler<THandler>(this RouteCollection routes, IKernel kernel, string name, string url)
{
- var route = new Route(url, new HttpHandlerRouteHandler(typeof(THandler)));
+ var route = new Route(url, new HttpHandlerRouteHandler(kernel, typeof(THandler)));
routes.Add(name, route);
return route;
}
View
62 Kudu.Services.Web/Kudu.Services.Web.csproj
@@ -38,58 +38,31 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Microsoft.ApplicationServer.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\WebApi.0.6.0\lib\40-Full\Microsoft.ApplicationServer.Http.dll</HintPath>
- </Reference>
<Reference Include="Microsoft.CSharp" />
- <Reference Include="Microsoft.Json, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\JsonValue.0.6.0\lib\40\Microsoft.Json.dll</HintPath>
- </Reference>
- <Reference Include="Microsoft.Net.Http.Formatting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\HttpClient.0.6.0\lib\40\Microsoft.Net.Http.Formatting.dll</HintPath>
- </Reference>
- <Reference Include="Microsoft.Runtime.Serialization.Internal, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\WebApi.0.6.0\lib\40-Full\Microsoft.Runtime.Serialization.Internal.dll</HintPath>
- </Reference>
- <Reference Include="Microsoft.Server.Common, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\WebApi.0.6.0\lib\40-Full\Microsoft.Server.Common.dll</HintPath>
- </Reference>
- <Reference Include="Microsoft.ServiceModel.Internal, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\WebApi.0.6.0\lib\40-Full\Microsoft.ServiceModel.Internal.dll</HintPath>
- </Reference>
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
- <Reference Include="Newtonsoft.Json, Version=4.0.7.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+ <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Newtonsoft.Json.4.0.7\lib\net40\Newtonsoft.Json.dll</HintPath>
+ <HintPath>..\packages\Newtonsoft.Json.4.5.5\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Ninject, Version=2.2.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
<HintPath>..\packages\Ninject.2.2.1.4\lib\net40-Full\Ninject.dll</HintPath>
</Reference>
- <Reference Include="Ninject.Extensions.Wcf">
- <HintPath>..\packages\Ninject.Extensions.Wcf.2.2.0.4\lib\net40-Full\Ninject.Extensions.Wcf.dll</HintPath>
- </Reference>
- <Reference Include="SignalR, Version=0.4.0.0, Culture=neutral, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\SignalR.Server.0.4.0.0\lib\net40\SignalR.dll</HintPath>
- </Reference>
- <Reference Include="SignalR.Hosting.AspNet">
- <HintPath>..\packages\SignalR.Hosting.AspNet.0.4.0.0\lib\net40\SignalR.Hosting.AspNet.dll</HintPath>
- </Reference>
<Reference Include="System.IO.Abstractions, Version=1.4.0.23, Culture=neutral, PublicKeyToken=d480b5b72fb413da, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\System.IO.Abstractions.1.4.0.23\lib\net35\System.IO.Abstractions.dll</HintPath>
</Reference>
- <Reference Include="System.Net.Http">
- <HintPath>..\packages\HttpClient.0.6.0\lib\40\System.Net.Http.dll</HintPath>
+ <Reference Include="System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\Microsoft.Net.Http.2.0.20522.0\lib\net40\System.Net.Http.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Net.Http.Formatting">
+ <HintPath>..\packages\Microsoft.AspNet.WebApi.Client.4.0.20522.0\lib\net40\System.Net.Http.Formatting.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Net.Http.WebRequest">
+ <HintPath>..\packages\Microsoft.Net.Http.2.0.20522.0\lib\net40\System.Net.Http.WebRequest.dll</HintPath>
</Reference>
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel.Activation" />
@@ -102,6 +75,12 @@
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.Extensions" />
+ <Reference Include="System.Web.Http">
+ <HintPath>..\packages\Microsoft.AspNet.WebApi.Core.4.0.20522.0\lib\net40\System.Web.Http.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Web.Http.WebHost">
+ <HintPath>..\packages\Microsoft.AspNet.WebApi.WebHost.4.0.20522.0\lib\net40\System.Web.Http.WebHost.dll</HintPath>
+ </Reference>
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Drawing" />
@@ -122,7 +101,6 @@
<ItemGroup>
<Content Include="Env.aspx" />
<Content Include="Default.aspx" />
- <Content Include="Global.asax" />
<Content Include="msbuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.Build.Tasks.Dll" />
<Content Include="msbuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.Dll" />
<Content Include="Web.config">
@@ -148,17 +126,13 @@
<Compile Include="Security\BlockLocalhostModule.cs" />
<Compile Include="Services\DeploymentEnvironment.cs" />
<Compile Include="Services\BuildPropertyProvider.cs" />
+ <Compile Include="Services\NinjectWebApiDependencyResolver.cs" />
<Compile Include="Tracing\TraceModule.cs" />
<Compile Include="Tracing\TraceServices.cs" />
<Compile Include="App_Start\NinjectServices.cs" />
<Compile Include="App_Start\PathResolver.cs" />
- <Compile Include="Tracing\TraceErrorHandler.cs" />
<Compile Include="Services\ServerConfiguration.cs" />
- <Compile Include="Global.asax.cs">
- <DependentUpon>Global.asax</DependentUpon>
- </Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Services\SimpleUserValidator.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Kudu.Contracts\Kudu.Contracts.csproj">
View
66 Kudu.Services.Web/Services/NinjectWebApiDependencyResolver.cs
@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.Contracts;
+using System.Web.Http.Dependencies;
+using Ninject;
+using Ninject.Syntax;
+
+namespace Kudu.Services.Web.Services
+{
+ public class NinjectDependencyScope : IDependencyScope
+ {
+ private IResolutionRoot _resolver;
+
+ internal NinjectDependencyScope(IResolutionRoot resolver)
+ {
+ _resolver = resolver;
+ }
+
+ public void Dispose()
+ {
+ IDisposable disposable = _resolver as IDisposable;
+ if (disposable != null)
+ {
+ disposable.Dispose();
+ }
+
+ _resolver = null;
+ }
+
+ public object GetService(Type serviceType)
+ {
+ if (_resolver == null)
+ {
+ throw new ObjectDisposedException("this", "This scope has already been disposed");
+ }
+
+ return _resolver.TryGet(serviceType);
+ }
+
+ public IEnumerable<object> GetServices(Type serviceType)
+ {
+ if (_resolver == null)
+ {
+ throw new ObjectDisposedException("this", "This scope has already been disposed");
+ }
+
+ return _resolver.GetAll(serviceType);
+ }
+ }
+
+ public class NinjectWebApiDependencyResolver : NinjectDependencyScope, IDependencyResolver
+ {
+ private readonly IKernel _kernel;
+
+ public NinjectWebApiDependencyResolver(IKernel kernel)
+ : base(kernel)
+ {
+ _kernel = kernel;
+ }
+
+ public IDependencyScope BeginScope()
+ {
+ return new NinjectDependencyScope(_kernel.BeginBlock());
+ }
+ }
+}
View
12 Kudu.Services.Web/Services/SimpleUserValidator.cs
@@ -1,12 +0,0 @@
-using Kudu.Services.Authorization;
-
-namespace Kudu.Services.Web
-{
- public class SimpleUserValidator : IUserValidator
- {
- public bool Validate(string username, string password)
- {
- return username == "admin" && password == "kudu";
- }
- }
-}
View
27 Kudu.Services.Web/Tracing/TraceErrorHandler.cs
@@ -1,27 +0,0 @@
-using System;
-using System.Net.Http;
-using Kudu.Contracts.Tracing;
-using Kudu.Core.Tracing;
-using Microsoft.ApplicationServer.Http.Dispatcher;
-
-namespace Kudu.Services.Web.Tracing
-{
- public class TraceErrorHandler : HttpErrorHandler
- {
- private readonly ITraceFactory _traceFactory;
-
- public TraceErrorHandler(ITraceFactory traceFactory)
- {
- _traceFactory = traceFactory;
- }
-
- protected override bool OnTryProvideResponse(Exception exception, ref HttpResponseMessage message)
- {
- ITracer tracer = _traceFactory.GetTracer();
-
- tracer.TraceError(exception);
-
- return false;
- }
- }
-}
View
11 Kudu.Services.Web/Web.config
@@ -26,12 +26,17 @@
</requestFiltering>
</security>
</system.webServer>
- <system.serviceModel>
- <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
- </system.serviceModel>
<system.net>
<defaultProxy enabled="true">
<proxy usesystemdefault="True" />
</defaultProxy>
</system.net>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
</configuration>
View
12 Kudu.Services.Web/packages.config
@@ -1,15 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="HttpClient" version="0.6.0" />
- <package id="JsonValue" version="0.6.0" />
+ <package id="Microsoft.AspNet.WebApi.Client" version="4.0.20522.0" />
+ <package id="Microsoft.AspNet.WebApi.Core" version="4.0.20522.0" />
+ <package id="Microsoft.AspNet.WebApi.WebHost" version="4.0.20522.0" />
+ <package id="Microsoft.Net.Http" version="2.0.20522.0" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
- <package id="Newtonsoft.Json" version="4.0.7" />
+ <package id="Newtonsoft.Json" version="4.5.5" />
<package id="Ninject" version="2.2.1.4" />
- <package id="Ninject.Extensions.Wcf" version="2.2.0.4" />
- <package id="SignalR.Hosting.AspNet" version="0.4.0.0" />
- <package id="SignalR.Server" version="0.4.0.0" />
<package id="System.IO.Abstractions" version="1.4.0.23" />
<package id="WebActivator" version="1.5" />
- <package id="WebApi" version="0.6.0" />
<package id="XmlSettings" version="0.1.1" />
</packages>
View
43 Kudu.Services/Authorization/BasicAuthorizeHandler.cs
@@ -1,43 +0,0 @@
-using System;
-using System.Net.Http;
-using System.Text;
-using Microsoft.ApplicationServer.Http.Dispatcher;
-
-namespace Kudu.Services.Authorization
-{
- public class BasicAuthorizeHandler : HttpOperationHandler<HttpRequestMessage, HttpRequestMessage>
- {
- private IUserValidator validator;
-
- public BasicAuthorizeHandler(IUserValidator validator)
- : base("authorizedClient")
- {
- this.validator = validator;
- }
-
- protected override HttpRequestMessage OnHandle(HttpRequestMessage input)
- {
- var authorizationHeader = input.Headers.Authorization;
-
- if (authorizationHeader != null)
- {
- byte[] encodedDataAsBytes = Convert.FromBase64String(authorizationHeader.Parameter);
- string value = Encoding.ASCII.GetString(encodedDataAsBytes);
- string username = value.Substring(0, value.IndexOf(':'));
- string password = value.Substring(value.IndexOf(':') + 1);
-
- if (validator.Validate(username, password))
- {
- return input;
- }
- }
-
- var unauthorizedResponse = new HttpResponseMessage(System.Net.HttpStatusCode.Unauthorized);
- unauthorizedResponse.Headers.WwwAuthenticate.Add(new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", "realm=\"My Server\""));
- unauthorizedResponse.Content = new StringContent("401, please authenticate");
-
- // Get the client to prompt for credentials
- throw new HttpResponseException(unauthorizedResponse);
- }
- }
-}
View
8 Kudu.Services/Authorization/IUserValidator.cs
@@ -1,8 +0,0 @@
-
-namespace Kudu.Services.Authorization
-{
- public interface IUserValidator
- {
- bool Validate(string username, string password);
- }
-}
View
32 Kudu.Services/Commands/CommandService.cs
@@ -1,32 +0,0 @@
-using System.ComponentModel;
-using System.Json;
-using System.ServiceModel;
-using System.ServiceModel.Web;
-using Kudu.Core.Commands;
-
-namespace Kudu.Services.Commands
-{
- [ServiceContract]
- public class CommandService
- {
- private readonly ICommandExecutor _executor;
- public CommandService(ICommandExecutor executor)
- {
- _executor = executor;
- }
-
- [Description("Remotely executes the specified command.")]
- [WebInvoke(UriTemplate = "run")]
- public void Run(JsonObject input)
- {
- _executor.ExecuteCommand((string)input["command"]);
- }
-
- [Description("Cancels a pending command.")]
- [WebInvoke(UriTemplate = "cancel")]
- public void Cancel()
- {
- _executor.CancelCommand();
- }
- }
-}
View
12 Kudu.Services/Commands/CommandStatusHandler.cs
@@ -1,12 +0,0 @@
-using SignalR;
-
-namespace Kudu.Services.Deployment
-{
- public class LiveCommandStatusHandler : PersistentConnection
- {
- }
-
- public class DevCommandStatusHandler : PersistentConnection
- {
- }
-}
View
101 ....Services/Deployment/DeploymentService.cs → ...rvices/Deployment/DeploymentController.cs
@@ -1,40 +1,35 @@
using System;
using System.Collections.Generic;
-using System.ComponentModel;
using System.Globalization;
using System.IO;
-using System.Json;
using System.Linq;
using System.Net;
using System.Net.Http;
-using System.ServiceModel;
-using System.ServiceModel.Web;
+using System.Web.Http;
using Kudu.Contracts.Infrastructure;
using Kudu.Contracts.Tracing;
using Kudu.Core.Deployment;
using Kudu.Services.Infrastructure;
-using Microsoft.ApplicationServer.Http.Dispatcher;
+using Newtonsoft.Json.Linq;
namespace Kudu.Services.Deployment
{
- [ServiceContract]
- public class DeploymentService
+ public class DeploymentController : ApiController
{
private readonly IDeploymentManager _deploymentManager;
private readonly ITracer _tracer;
private readonly IOperationLock _deploymentLock;
- public DeploymentService(ITracer tracer,
- IDeploymentManager deploymentManager,
- IOperationLock deploymentLock)
+ public DeploymentController(ITracer tracer,
+ IDeploymentManager deploymentManager,
+ IOperationLock deploymentLock)
{
_tracer = tracer;
_deploymentManager = deploymentManager;
_deploymentLock = deploymentLock;
}
- [Description("Deletes a deployment.")]
- [WebInvoke(UriTemplate = "{id}", Method = "DELETE")]
+ [HttpDelete]
public void Delete(string id)
{
using (_tracer.Step("DeploymentService.Delete"))
@@ -47,26 +42,22 @@ public void Delete(string id)
}
catch (DirectoryNotFoundException ex)
{
- var response = new HttpResponseMessage(HttpStatusCode.NotFound);
- response.Content = new StringContent(ex.Message);
- throw new HttpResponseException(response);
+ throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
}
catch (InvalidOperationException ex)
{
- var response = new HttpResponseMessage(HttpStatusCode.Conflict);
- response.Content = new StringContent(ex.Message);
- throw new HttpResponseException(response);
+ throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.Conflict, ex));
}
});
}
}
- [Description("Deploys a specific deployment based on its id.")]
- [WebInvoke(Method = "PUT", UriTemplate = "{id}")]
- public void Deploy(HttpRequestMessage request, string id)
+ [HttpPut]
+ public void Deploy(string id)
{
+ JObject result = GetJsonContent();
+
// Just block here to read the json payload from the body
- var result = request.Content.ReadAsAsync<JsonValue>().Result;
using (_tracer.Step("DeploymentService.Deploy(id)"))
{
_deploymentLock.LockHttpOperation(() =>
@@ -77,49 +68,45 @@ public void Deploy(HttpRequestMessage request, string id)
if (result != null)
{
- JsonValue cleanValue = result["clean"];
- clean = cleanValue != null && cleanValue.ReadAs<bool>();
+ clean = result.Value<bool>("clean");
}
string username = null;
- AuthUtility.TryExtractBasicAuthUser(request, out username);
+ AuthUtility.TryExtractBasicAuthUser(Request, out username);
_deploymentManager.Deploy(id, username, clean);
}
catch (FileNotFoundException ex)
{
- var response = new HttpResponseMessage(HttpStatusCode.NotFound);
- response.Content = new StringContent(ex.Message);
- throw new HttpResponseException(response);
+ throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
}
});
}
}
-
- [Description("Gets the deployment results of all deployments.")]
- [WebGet(UriTemplate = "")]
- public IQueryable<DeployResult> GetDeployResults(HttpRequestMessage request)
+
+ [HttpGet]
+ [Queryable]
+ public IQueryable<DeployResult> GetDeployResults()
{
using (_tracer.Step("DeploymentService.GetDeployResults"))
{
- return GetResults(request).AsQueryable();
+ return GetResults(Request).AsQueryable();
}
}
- [Description("Gets the log of a specific deployment based on its id.")]
- [WebGet(UriTemplate = "{id}/log")]
- public IEnumerable<LogEntry> GetLogEntry(HttpRequestMessage request, string id)
+ [HttpGet]
+ public IEnumerable<LogEntry> GetLogEntry(string id)
{
using (_tracer.Step("DeploymentService.GetLogEntry"))
{
try
{
- var deployments = _deploymentManager.GetLogEntries(id).ToList();
+ IEnumerable<LogEntry> deployments = _deploymentManager.GetLogEntries(id).ToList();
foreach (var entry in deployments)
{
if (entry.HasDetails)
{
- entry.DetailsUrl = UriHelper.MakeRelative(request.RequestUri, entry.Id);
+ entry.DetailsUrl = UriHelper.MakeRelative(Request.RequestUri, entry.Id);
}
}
@@ -127,15 +114,12 @@ public IEnumerable<LogEntry> GetLogEntry(HttpRequestMessage request, string id)
}
catch (FileNotFoundException ex)
{
- var response = new HttpResponseMessage(HttpStatusCode.NotFound);
- response.Content = new StringContent(ex.Message);
- throw new HttpResponseException(response);
+ throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
}
}
}
- [Description("Gets the specified log entry details.")]
- [WebGet(UriTemplate = "{id}/log/{logId}")]
+ [HttpGet]
public IEnumerable<LogEntry> GetLogEntryDetails(string id, string logId)
{
using (_tracer.Step("DeploymentService.GetLogEntryDetails"))
@@ -146,16 +130,13 @@ public IEnumerable<LogEntry> GetLogEntryDetails(string id, string logId)
}
catch (FileNotFoundException ex)
{
- var response = new HttpResponseMessage(HttpStatusCode.NotFound);
- response.Content = new StringContent(ex.Message);
- throw new HttpResponseException(response);
+ throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
}
}
}
- [Description("Gets the deployment result of a specific deployment based on its id.")]
- [WebGet(UriTemplate = "{id}")]
- public DeployResult GetResult(HttpRequestMessage request, string id)
+ [HttpGet]
+ public DeployResult GetResult(string id)
{
using (_tracer.Step("DeploymentService.GetResult"))
{
@@ -163,15 +144,14 @@ public DeployResult GetResult(HttpRequestMessage request, string id)
if (result == null)
{
- var response = new HttpResponseMessage(HttpStatusCode.NotFound);
- response.Content = new StringContent(String.Format(CultureInfo.CurrentCulture,
+ var response = Request.CreateErrorResponse(HttpStatusCode.NotFound, String.Format(CultureInfo.CurrentCulture,
Resources.Error_DeploymentNotFound,
id));
throw new HttpResponseException(response);
}
- result.Url = request.RequestUri;
- result.LogUrl = UriHelper.MakeRelative(request.RequestUri, "log");
+ result.Url = Request.RequestUri;
+ result.LogUrl = UriHelper.MakeRelative(Request.RequestUri, "log");
return result;
}
@@ -186,5 +166,20 @@ private IEnumerable<DeployResult> GetResults(HttpRequestMessage request)
yield return result;
}
}
+
+ private JObject GetJsonContent()
+ {
+ try
+ {
+ return Request.Content.ReadAsAsync<JObject>().Result;
+ }
+ catch
+ {
+ // We're going to return null here since we don't want to force a breaking change
+ // on the client side. If the incoming request isn't application/json, we want this
+ // to return null.
+ return null;
+ }
+ }
}
}
View
14 ...ervices/Diagnostics/DiagnosticsService.cs → ...ices/Diagnostics/DiagnosticsController.cs
@@ -2,30 +2,28 @@
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
-using System.ServiceModel;
-using System.ServiceModel.Web;
+using System.Web.Http;
using Ionic.Zip;
using Kudu.Services.Infrastructure;
namespace Kudu.Services.Performance
{
- [ServiceContract]
- public class DiagnosticsService
+ public class DiagnosticsController : ApiController
{
private readonly string[] _paths;
private static object _lockObj = new object();
- public DiagnosticsService(params string[] paths)
+ public DiagnosticsController(params string[] paths)
{
_paths = paths;
}
- [WebGet(UriTemplate = "")]
- public HttpResponseMessage GetDiagnostics()
+ [HttpGet]
+ public HttpResponseMessage GetLog()
{
lock (_lockObj)
{
- var response = new HttpResponseMessage();
+ HttpResponseMessage response = Request.CreateResponse();
using (var zip = new ZipFile())
{
foreach (var path in _paths)
View
46 Kudu.Services/Editor/FilesController.cs
@@ -0,0 +1,46 @@
+using System.Net.Http;
+using System.Text;
+using System.Web.Http;
+using Kudu.Core.Editor;
+using Newtonsoft.Json.Linq;
+
+namespace Kudu.Services.Documents
+{
+ public class FilesController : ApiController
+ {
+ private readonly IProjectSystem _projectSystem;
+
+ public FilesController(IProjectSystem projectSystem)
+ {
+ _projectSystem = projectSystem;
+ }
+
+ [HttpGet]
+ public Project GetFiles()
+ {
+ return _projectSystem.GetProject();
+ }
+
+ [HttpGet]
+ public HttpResponseMessage GetFile(string path)
+ {
+ var content = new StringContent(_projectSystem.ReadAllText(path), Encoding.UTF8);
+ var response = new HttpResponseMessage();
+ response.Content = content;
+ return response;
+ }
+
+ [HttpPut]
+ public void Save(string path, JObject input)
+ {
+ string content = input.Value<string>("content");
+ _projectSystem.WriteAllText(path, content);
+ }
+
+ [HttpDelete]
+ public void Delete(string path)
+ {
+ _projectSystem.Delete(path);
+ }
+ }
+}
View
51 Kudu.Services/Editor/FilesService.cs
@@ -1,51 +0,0 @@
-using System.ComponentModel;
-using System.Json;
-using System.Net.Http;
-using System.ServiceModel;
-using System.ServiceModel.Web;
-using Kudu.Core.Editor;
-
-namespace Kudu.Services.Documents
-{
- [ServiceContract]
- public class FilesService
- {
- private readonly IProjectSystem _projectSystem;
-
- public FilesService(IProjectSystem projectSystem)
- {
- _projectSystem = projectSystem;
- }
-
- [Description("Gets the project.")]
- [WebGet(UriTemplate = "")]
- public Project GetProject()
- {
- return _projectSystem.GetProject();
- }
-
- [Description("Gets the specified file.")]
- [WebGet(UriTemplate = "?path={path}")]
- public HttpResponseMessage GetFile(string path)
- {
- var content = new StringContent(_projectSystem.ReadAllText(path), System.Text.Encoding.UTF8);
- var response = new HttpResponseMessage();
- response.Content = content;
- return response;
- }
-
- [Description("Saves the specified file.")]
- [WebInvoke(UriTemplate = "save")]
- public void Save(JsonObject input)
- {
- _projectSystem.WriteAllText((string)input["path"], (string)input["content"]);
- }
-
- [Description("Deletes the specified file.")]
- [WebInvoke(UriTemplate = "delete")]
- public void Delete(JsonObject input)
- {
- _projectSystem.Delete((string)input["path"]);
- }
- }
-}
View
40 Kudu.Services/GitServer/InfoRefsService.cs → ....Services/GitServer/InfoRefsController.cs
@@ -19,28 +19,23 @@
// This file was modified from the one found in git-dot-aspx
#endregion
+using System;
+using System.IO;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.ServiceModel.Web;
+using System.Web.Http;
+using Kudu.Contracts.SourceControl;
+using Kudu.Contracts.Tracing;
+using Kudu.Core;
+using Kudu.Core.Deployment;
+using Kudu.Core.SourceControl.Git;
+using Kudu.Services.Infrastructure;
namespace Kudu.Services.GitServer
-{
- using System;
- using System.ComponentModel;
- using System.IO;
- using System.Net;
- using System.Net.Http;
- using System.Net.Http.Headers;
- using System.ServiceModel;
- using System.ServiceModel.Web;
- using Kudu.Contracts.SourceControl;
- using Kudu.Contracts.Tracing;
- using Kudu.Core;
- using Kudu.Core.Deployment;
- using Kudu.Core.SourceControl;
- using Kudu.Core.SourceControl.Git;
- using Kudu.Services.Infrastructure;
-
- // Handles /{project}/info/refs
- [ServiceContract]
- public class InfoRefsService
+{
+ public class InfoRefsController : ApiController
{
private readonly IDeploymentManager _deploymentManager;
private readonly IGitServer _gitServer;
@@ -48,7 +43,7 @@ public class InfoRefsService
private readonly string _deploymentTargetPath;
private readonly RepositoryConfiguration _configuration;
- public InfoRefsService(
+ public InfoRefsController(
ITracer tracer,
IGitServer gitServer,
IDeploymentManager deploymentManager,
@@ -62,8 +57,7 @@ public class InfoRefsService
_configuration = configuration;
}
- [Description("Handles git commands.")]
- [WebGet(UriTemplate = "?service={service}")]
+ [HttpGet]
public HttpResponseMessage Execute(string service)
{
using (_tracer.Step("InfoRefsService.Execute"))
View
4 ....Services/GitServer/ReceivePackService.cs → ....Services/GitServer/ReceivePackHandler.cs
@@ -8,13 +8,13 @@
namespace Kudu.Services.GitServer
{
- public class ReceivePackService : IHttpHandler
+ public class ReceivePackHandler : IHttpHandler
{
private readonly IGitServer _gitServer;
private readonly ITracer _tracer;
private readonly IOperationLock _deploymentLock;
- public ReceivePackService(ITracer tracer,
+ public ReceivePackHandler(ITracer tracer,
IGitServer gitServer,
IOperationLock deploymentLock)
{
View
16 Kudu.Services/GitServer/RpcService.cs → Kudu.Services/GitServer/RpcController.cs
@@ -22,34 +22,26 @@
namespace Kudu.Services.GitServer
{
- using System;
- using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.IO.Compression;
- using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.ServiceModel;
using System.ServiceModel.Web;
- using System.Text;
- using System.Threading;
- using System.Web.Hosting;
+ using System.Web.Http;
using Kudu.Contracts.Infrastructure;
using Kudu.Contracts.Tracing;
- using Kudu.Core.Deployment;
using Kudu.Core.SourceControl.Git;
using Kudu.Services.Infrastructure;
- // Handles {project}/git-upload-pack and {project}/git-receive-pack
- [ServiceContract]
- public class RpcService
+ public class RpcController : ApiController
{
private readonly IGitServer _gitServer;
private readonly ITracer _tracer;
private readonly IOperationLock _deploymentLock;
- public RpcService(ITracer tracer,
+ public RpcController(ITracer tracer,
IGitServer gitServer,
IOperationLock deploymentLock)
{
@@ -58,8 +50,6 @@ public class RpcService
_deploymentLock = deploymentLock;
}
- [Description("Handles a 'git pull' command.")]
- [WebInvoke(UriTemplate = "git-upload-pack")]
public HttpResponseMessage UploadPack(HttpRequestMessage request)
{
using (_tracer.Step("RpcService.UploadPack"))
View
2  Kudu.Services/Infrastructure/LockExtensions.cs
@@ -1,8 +1,8 @@
using System;
using System.Net;
using System.Net.Http;
+using System.Web.Http;
using Kudu.Contracts.Infrastructure;
-using Microsoft.ApplicationServer.Http.Dispatcher;
namespace Kudu.Services.Infrastructure
{
View
62 Kudu.Services/Kudu.Services.csproj
@@ -36,37 +36,13 @@
<Reference Include="Ionic.Zip">
<HintPath>..\packages\DotNetZip.1.9.1.8\lib\net20\Ionic.Zip.dll</HintPath>
</Reference>
- <Reference Include="Microsoft.ApplicationServer.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\WebApi.0.6.0\lib\40-Full\Microsoft.ApplicationServer.Http.dll</HintPath>
- </Reference>
- <Reference Include="Microsoft.Json, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\JsonValue.0.6.0\lib\40\Microsoft.Json.dll</HintPath>
- </Reference>
- <Reference Include="Microsoft.Net.Http.Formatting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\HttpClient.0.6.0\lib\40\Microsoft.Net.Http.Formatting.dll</HintPath>
- </Reference>
- <Reference Include="Microsoft.Runtime.Serialization.Internal, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\WebApi.0.6.0\lib\40-Full\Microsoft.Runtime.Serialization.Internal.dll</HintPath>
- </Reference>
- <Reference Include="Microsoft.Server.Common, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\WebApi.0.6.0\lib\40-Full\Microsoft.Server.Common.dll</HintPath>
- </Reference>
- <Reference Include="Microsoft.ServiceModel.Internal, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\WebApi.0.6.0\lib\40-Full\Microsoft.ServiceModel.Internal.dll</HintPath>
- </Reference>
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
- <Reference Include="Newtonsoft.Json, Version=4.0.7.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+ <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Newtonsoft.Json.4.0.7\lib\net40\Newtonsoft.Json.dll</HintPath>
+ <HintPath>..\packages\Newtonsoft.Json.4.5.5\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="SignalR, Version=0.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
@@ -74,14 +50,24 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
- <Reference Include="System.Net.Http">
- <HintPath>..\packages\HttpClient.0.6.0\lib\40\System.Net.Http.dll</HintPath>
+ <Reference Include="System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\Microsoft.Net.Http.2.0.20521.0\lib\net40\System.Net.Http.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Net.Http.Formatting">
+ <HintPath>..\packages\Microsoft.AspNet.WebApi.Client.4.0.20521.0\lib\net40\System.Net.Http.Formatting.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Net.Http.WebRequest">
+ <HintPath>..\packages\Microsoft.Net.Http.2.0.20521.0\lib\net40\System.Net.Http.WebRequest.dll</HintPath>
</Reference>
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel.Activation" />
<Reference Include="System.ServiceModel.Web" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
+ <Reference Include="System.Web.Http">
+ <HintPath>..\packages\Microsoft.AspNet.WebApi.Core.4.0.20521.0\lib\net40\System.Web.Http.dll</HintPath>
+ </Reference>
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
@@ -99,19 +85,15 @@
</Reference>
</ItemGroup>
<ItemGroup>
- <Compile Include="Authorization\BasicAuthorizeHandler.cs" />
- <Compile Include="Authorization\IUserValidator.cs" />
- <Compile Include="Commands\CommandService.cs" />
- <Compile Include="Commands\CommandStatusHandler.cs" />
- <Compile Include="Deployment\DeploymentService.cs" />
- <Compile Include="Editor\FilesService.cs" />
+ <Compile Include="Deployment\DeploymentController.cs" />
+ <Compile Include="Editor\FilesController.cs" />
<Compile Include="GitServer\Helpers.cs" />
- <Compile Include="GitServer\InfoRefsService.cs" />
- <Compile Include="GitServer\ReceivePackService.cs" />
- <Compile Include="GitServer\RpcService.cs" />
+ <Compile Include="GitServer\InfoRefsController.cs" />
+ <Compile Include="GitServer\ReceivePackHandler.cs" />
+ <Compile Include="GitServer\RpcController.cs" />
<Compile Include="Infrastructure\AuthUtility.cs" />
<Compile Include="Infrastructure\IServerConfiguration.cs" />
- <Compile Include="Diagnostics\DiagnosticsService.cs" />
+ <Compile Include="Diagnostics\DiagnosticsController.cs" />
<Compile Include="Infrastructure\LockExtensions.cs" />
<Compile Include="Infrastructure\MemoryStreamExtensions.cs" />
<Compile Include="Infrastructure\UriHelper.cs" />
@@ -121,9 +103,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
- <Compile Include="Settings\ConnectionStringsService.cs" />
- <Compile Include="Settings\AppSettingsService.cs" />
- <Compile Include="SourceControl\DeploymentSourceControlService.cs" />
+ <Compile Include="SourceControl\LiveScmController.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
View
40 Kudu.Services/Settings/AppSettingsService.cs
@@ -1,40 +0,0 @@
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Json;
-using System.ServiceModel;
-using System.ServiceModel.Web;
-using Kudu.Core.Deployment;
-
-namespace Kudu.Services.Settings
-{
- [ServiceContract]
- public class AppSettingsService
- {
- private readonly IDeploymentSettingsManager _settingsManager;
- public AppSettingsService(IDeploymentSettingsManager settingsManager)
- {
- _settingsManager = settingsManager;
- }
-
- [Description("Gets the current set of environment variables.")]
- [WebGet(UriTemplate = "")]
- public IEnumerable<DeploymentSetting> Index()
- {
- return _settingsManager.GetAppSettings();
- }
-
- [Description("Creates or sets an environment variable.")]
- [WebInvoke(UriTemplate = "set")]
- public void Set(JsonObject input)
- {
- _settingsManager.SetAppSetting((string)input["key"], (string)input["value"]);
- }
-
- [Description("Removes an environment variable.")]
- [WebInvoke(UriTemplate = "remove")]
- public void Remove(JsonObject input)
- {
- _settingsManager.RemoveAppSetting((string)input["key"]);
- }
- }
-}
View
40 Kudu.Services/Settings/ConnectionStringsService.cs
@@ -1,40 +0,0 @@
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Json;
-using System.ServiceModel;
-using System.ServiceModel.Web;
-using Kudu.Core.Deployment;
-
-namespace Kudu.Services.Settings
-{
- [ServiceContract]
- public class ConnectionStringsService
- {
- private readonly IDeploymentSettingsManager _settingsManager;
- public ConnectionStringsService(IDeploymentSettingsManager settingsManager)
- {
- _settingsManager = settingsManager;
- }
-
- [Description("Gets the current set of connection strings.")]
- [WebGet(UriTemplate = "")]
- public IEnumerable<ConnectionStringSetting> Index()
- {
- return _settingsManager.GetConnectionStrings();
- }
-
- [Description("Creates or sets a connection string.")]
- [WebInvoke(UriTemplate = "set")]
- public void Set(JsonObject input)
- {
- _settingsManager.SetConnectionString((string)input["key"], (string)input["value"]);
- }
-
- [Description("Removes a connection string.")]
- [WebInvoke(UriTemplate = "remove")]
- public void Remove(JsonObject input)
- {
- _settingsManager.RemoveConnectionString((string)input["key"]);
- }
- }
-}
View
13 ...Control/DeploymentSourceControlService.cs → ...rvices/SourceControl/LiveScmController.cs
@@ -1,27 +1,25 @@
using System;
using System.ComponentModel;
using System.Net.Http;
-using System.ServiceModel;
using System.ServiceModel.Web;
+using System.Web.Http;
using Kudu.Core.SourceControl;
using Kudu.Services.Infrastructure;
namespace Kudu.Services.SourceControl
{
- [ServiceContract]
- public class DeploymentSourceControlService
+ public class LiveScmController : ApiController
{
private readonly IServerRepository _repository;
private readonly IServerConfiguration _serverConfiguration;
- public DeploymentSourceControlService(IServerRepository repository, IServerConfiguration serverConfiguration)
+ public LiveScmController(IServerRepository repository, IServerConfiguration serverConfiguration)
{
_repository = repository;
_serverConfiguration = serverConfiguration;
}
- [Description("Gets the repository information.")]
- [WebGet(UriTemplate = "info")]
+ [HttpGet]
public RepositoryInfo GetRepositoryInfo(HttpRequestMessage request)
{
var baseUri = new Uri(request.RequestUri.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped));
@@ -32,8 +30,7 @@ public RepositoryInfo GetRepositoryInfo(HttpRequestMessage request)
};
}
- [Description("Does a clean of the repository.")]
- [WebInvoke(UriTemplate = "clean", Method = "POST")]
+ [HttpPost]
public void Clean()
{
_repository.Clean();
View
8 Kudu.Services/packages.config
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="DotNetZip" version="1.9.1.8" />
- <package id="HttpClient" version="0.6.0" />
- <package id="JsonValue" version="0.6.0" />
+ <package id="Microsoft.AspNet.WebApi.Client" version="4.0.20521.0" />
+ <package id="Microsoft.AspNet.WebApi.Core" version="4.0.20521.0" />
+ <package id="Microsoft.Net.Http" version="2.0.20521.0" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
- <package id="Newtonsoft.Json" version="4.0.7" />
+ <package id="Newtonsoft.Json" version="4.5.5" />
<package id="SignalR.Server" version="0.4.0.0" />
<package id="WebActivator" version="1.5" />
- <package id="WebApi" version="0.6.0" />
<package id="XmlSettings" version="0.1.1" />
</packages>
Please sign in to comment.
Something went wrong with that request. Please try again.