Converted to NET Standard 2.0

This commit is contained in:
Michael Nolan
2022-04-03 10:36:38 -05:00
parent dc581343a4
commit 9244284c44
15 changed files with 128 additions and 245 deletions
+57 -56
View File
@@ -1,56 +1,57 @@
using Tesses;
using Tesses.WebServer;
namespace Tesses.WebServer.ConsoleApp
{
class MainClass
{
public static void Main(string[] args)
{
TestObject some_object = new TestObject();
RouteServer rserver = new RouteServer();
rserver.Add("/", async(ctx) => {
await ctx.SendJsonAsync(some_object);
});
rserver.Add("/page", async(ctx) => {
await ctx.SendTextAsync("Demetria Devonne Lovato 8/20/1992");
});
var ip=System.Net.IPAddress.Any;
StaticServer static_server = new StaticServer(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyVideos));
MountableServer mountable = new MountableServer(static_server);
mountable.Mount("/api/",new DynamicServer());
BasicAuthServer basicAuth = new BasicAuthServer((user, pass) => { return user == "demi" && pass == "password123"; }, rserver, "RouteServer"); //bad pasword I know, This is a sample
mountable.Mount("/api/route/",basicAuth);
HttpServerListener s = new HttpServerListener(new System.Net.IPEndPoint(ip, 24240),mountable);
/*
So this sample application
Route Server (Like dajuric/simple-http's routes (uses modified code from that project))
(In this example It is password protected, Username: "demi", Password: "password123")
I know password123 is a bad password (but its ok for this sample project)
/api/route/page: shows authors favorite artist and the birthday
/api/route/: shows authors name, birthday, gender
Dynamic Server (native api)
/api/rand: shows how you can use query params
/api/count: counts up every time you go to it
everything else is files in My Videos
*/
s.ListenAsync(System.Threading.CancellationToken.None).Wait();
}
public class TestObject
{
public string name => "Mike Nolan";
public int month => 12;
public int day => 2;
public int year => 2000;
public string gender => "Male"; //duh
}
}
}
using Tesses;
using Tesses.WebServer;
namespace Tesses.WebServer.ConsoleApp
{
class MainClass
{
public static void Main(string[] args)
{
TestObject some_object = new TestObject();
RouteServer rserver = new RouteServer();
rserver.Add("/", async(ctx) => {
await ctx.SendJsonAsync(some_object);
});
rserver.Add("/page", async(ctx) => {
await ctx.SendTextAsync("Demetria Devonne Lovato 8/20/1992");
});
var ip=System.Net.IPAddress.Any;
StaticServer static_server = new StaticServer(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyVideos));
MountableServer mountable = new MountableServer(static_server);
mountable.Mount("/api/",new DynamicServer());
BasicAuthServer basicAuth = new BasicAuthServer((user, pass) => { return user == "demi" && pass == "password123"; }, rserver, "RouteServer"); //bad pasword I know, This is a sample
mountable.Mount("/api/route/",basicAuth);
HttpServerListener s = new HttpServerListener(new System.Net.IPEndPoint(ip, 24240),mountable);
/*
So this sample application
Route Server (Like dajuric/simple-http's routes (uses modified code from that project))
(In this example It is password protected, Username: "demi", Password: "password123")
I know password123 is a bad password (but its ok for this sample project)
/api/route/page: shows authors favorite artist and the birthday
/api/route/: shows authors name, birthday, gender
Dynamic Server (native api)
/api/rand: shows how you can use query params
/api/count: counts up every time you go to it
everything else is files in My Videos
*/
s.ListenAsync(System.Threading.CancellationToken.None).Wait();
}
public class TestObject
{
public string name => "Mike Nolan";
public int month => 12;
public int day => 2;
public int year => 2000;
public string gender => "Male"; //duh
}
}
}
@@ -1,26 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle("Tesses.WebServer.Console")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("${AuthorCopyright}")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion("1.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]
+1
View File
@@ -83,3 +83,4 @@ namespace Tesses.WebServer.ConsoleApp
}
}
}
@@ -1,55 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\Tesses.WebServer.NetStandard\Tesses.WebServer.NetStandard.csproj" />
</ItemGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{3E464D71-CC54-4E71-9C8F-60B0ADF11EC1}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Tesses.WebServer.Console</RootNamespace>
<AssemblyName>Tesses.WebServer.Console</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ExternalConsole>true</ExternalConsole>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ExternalConsole>true</ExternalConsole>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="MimeTypesMap">
<HintPath>..\packages\MimeTypesMap.1.0.8\lib\net452\MimeTypesMap.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Server.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Tesses.WebServer\Tesses.WebServer.csproj">
<Project>{24949E8A-6661-4853-B2A2-FC957C1B58C3}</Project>
<Name>Tesses.WebServer</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
-5
View File
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MimeTypesMap" version="1.0.8" targetFramework="net47" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net47" />
</packages>