Skip to content

Commit

Permalink
添加了对静态资源的支持,优化了HTTP头的写入,增加一个web的例子。
Browse files Browse the repository at this point in the history
  • Loading branch information
beetlex-io committed Sep 18, 2018
1 parent cf9b8b5 commit 8ccfd62
Show file tree
Hide file tree
Showing 29 changed files with 1,476 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -12,3 +12,5 @@ HttpApiServer.Filters/bin/
HttpApiServer.Filters/obj/
samples/HttpApiServer.Filters/bin/
samples/HttpApiServer.Filters/obj/
samples/HttpApiServer.Web/bin/
samples/HttpApiServer.Web/obj/
Binary file modified .vs/BeetleX.FastHttpApi/v15/.suo
Binary file not shown.
7 changes: 7 additions & 0 deletions BeetleX.FastHttpApi.sln
Expand Up @@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HttpApiServer.JsonBody", "s
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HttpApiServer.Filters", "samples\HttpApiServer.Filters\HttpApiServer.Filters.csproj", "{92EB6BC1-7680-4684-87ED-FD2034F81F22}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpApiServer.Web", "samples\HttpApiServer.Web\HttpApiServer.Web.csproj", "{9277DD69-CCD4-4A94-B369-193D1664B0D3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -35,6 +37,10 @@ Global
{92EB6BC1-7680-4684-87ED-FD2034F81F22}.Debug|Any CPU.Build.0 = Debug|Any CPU
{92EB6BC1-7680-4684-87ED-FD2034F81F22}.Release|Any CPU.ActiveCfg = Release|Any CPU
{92EB6BC1-7680-4684-87ED-FD2034F81F22}.Release|Any CPU.Build.0 = Release|Any CPU
{9277DD69-CCD4-4A94-B369-193D1664B0D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9277DD69-CCD4-4A94-B369-193D1664B0D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9277DD69-CCD4-4A94-B369-193D1664B0D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9277DD69-CCD4-4A94-B369-193D1664B0D3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -43,6 +49,7 @@ Global
{1BB90467-89FD-459F-B2C4-B15CBA7F1B0F} = {74AFF152-DF0F-4D19-8CF1-5453E95C126F}
{31720C8E-983C-48E5-8CF7-35C273A1A42B} = {74AFF152-DF0F-4D19-8CF1-5453E95C126F}
{92EB6BC1-7680-4684-87ED-FD2034F81F22} = {74AFF152-DF0F-4D19-8CF1-5453E95C126F}
{9277DD69-CCD4-4A94-B369-193D1664B0D3} = {74AFF152-DF0F-4D19-8CF1-5453E95C126F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {988EEA11-1C48-44A4-9DF0-1C3D08600A4F}
Expand Down
42 changes: 42 additions & 0 deletions samples/HttpApiServer.Web/HttpApiServer.Web.csproj
@@ -0,0 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\BeetleX.FastHttpApi.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="HttpConfig.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="views\images\bg.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="views\images\pic1.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="views\images\pic2.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="views\images\shadow.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="views\index.html">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="views\license.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="views\style.css">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="views\test.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
13 changes: 13 additions & 0 deletions samples/HttpApiServer.Web/HttpConfig.json
@@ -0,0 +1,13 @@
{
"HttpConfig": {
"Host": "",
"Port": 9090,
"SSL": false,
"CertificateFile": "",
"CertificatePassword": "",
"MaxBodyLength": 2097152,
"OutputStackTrace": false,
"StaticResurceType": "jpg=image/jpeg;jpeg=image/jpeg;gif=image/gif;png=image/png;js=application/x-javascript;html=text/html;htm=text/html;css=text/css;txt=text/plain",
"DefaultPage": "index.html;index.htm"
}
}
20 changes: 20 additions & 0 deletions samples/HttpApiServer.Web/Program.cs
@@ -0,0 +1,20 @@
using BeetleX.FastHttpApi;
using System;

namespace HttpApiServer.Web
{
class Program
{
private static BeetleX.FastHttpApi.HttpApiServer mApiServer;

static void Main(string[] args)
{
mApiServer = new BeetleX.FastHttpApi.HttpApiServer();
mApiServer.ServerConfig.BodySerializer = new JsonBodySerializer();
mApiServer.Register(typeof(Program).Assembly);
mApiServer.Open();
Console.Write(mApiServer.BaseServer);
Console.Read();
}
}
}
Binary file added samples/HttpApiServer.Web/views/images/bg.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/HttpApiServer.Web/views/images/pic1.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/HttpApiServer.Web/views/images/pic2.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/HttpApiServer.Web/views/images/shadow.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
160 changes: 160 additions & 0 deletions samples/HttpApiServer.Web/views/index.html
@@ -0,0 +1,160 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Coffeelike by nodethirtythree + Templated.org
http://templated.org/ | @templatedorg
Released under the Creative Commons Attribution 3.0 License.
Note from the author: These templates take quite a bit of time to conceive,
design, and finally code. So please, support our efforts by respecting our
license: keep our footer credit links intact so people can find out about us
and what we do. It's the right thing to do, and we'll love you for it :)
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Coffeelike | Designed by nodethirtythree + Templated.org</title>
<link href="http://fonts.googleapis.com/css?family=Arvo" rel="stylesheet" type="text/css" />
<link href="http://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="bg">
<div id="outer">
<div id="header">
<div id="logo">
<h1>
<a href="#">Coffeelike</a>
</h1>
</div>
<div id="nav">
<ul>
<li class="first active">
<a href="#">Home</a>
</li>
<li>
<a href="#">Services</a>
</li>
<li>
<a href="#">Portfolio</a>
</li>
<li>
<a href="#">About</a>
</li>
<li>
<a href="#">Blog</a>
</li>
<li class="last">
<a href="#">Contact</a>
</li>
</ul>
<br class="clear" />
</div>
</div>
<div id="main">
<div id="sidebar">
<h3>
Feugiat sem praesent
</h3>
<p>
Aliquam sed vulputate curabitur convallis dignissim. Phasellus sed convallis condimentum et amet
hendrerit neque sit euismod.
</p>
<h3>
Suscipit commodo lacinia
</h3>
<ul class="linkedList">
<li class="first">
<a href="#">Ridiculus dolore felis</a>
</li>
<li>
<a href="#">Cras velit vestibulum penatibus</a>
</li>
<li>
<a href="#">Eleifend porttitor auctor</a>
</li>
<li>
<a href="#">Semper erat sed consequat</a>
</li>
<li>
<a href="#">Integer egestas sodales</a>
</li>
<li class="last">
<a href="#">Aliquet cras odio tristique</a>
</li>
</ul>
</div>
<div id="content">
<div id="box1">
<h2>
Welcome to Coffeelike
</h2>
<img class="left" src="images/pic1.jpg" width="130" height="160" alt="" />
<p>
This is <strong>Coffeelike</strong>, a two column CSS template by
<a href="http://nodethirtythree.com/">nodethirtythree</a> + <a href="http://templated.org/">Templated.org</a> with photos from
<a href="http://www.pdphoto.org/">PDPhoto</a>. It's released (for free) under the
<a href="http://templated.org/license/">Creative Commons Attribution 3.0 license</a>,
so feel free to use it for any personal or commercial work, just keep our footer credit links intact.
Hit up our <a href="http://templated.org/">website</a> for more awesomely
cool free templates, and follow us on <a href="http://twitter.com/templatedorg">Twitter</a>
(<a href="http://twitter.com/templatedorg">@templatedorg</a>) for updates, announcements, and other
mildly interesting ramblings.
</p>
</div>
<div id="box2">
<h3>
Primis dolor fringilla porta
</h3>
<ul class="imageList">
<li class="first">
<img class="left" src="images/pic2.jpg" width="80" height="80" alt="" /> <span>Quis faucibus mauris quis consectetur lobortis parturient sit turpis scelerisque neque aliquet.</span>
</li>
<li>
<img class="left" src="images/pic1.jpg" width="80" height="80" alt="" /> <span>Lobortis malesuada penatibus porta varius ligula blandit sit dolor mattis morbi ullamcorper posuere tempus.</span>
</li>
<li class="last">
<img class="left" src="images/pic2.jpg" width="80" height="80" alt="" /> <span>Diam nunc turpis placerat imperdiet ac cras ac sociis aliquam sed lacinia augue suspendisse.</span>
</li>
</ul>
</div>
<div id="box3">
<h3>
Magnis felis
</h3>
<p>
Vulputate magna nibh augue. Rutrum nibh sodales porta etiam.
</p>
<ul class="linkedList">
<li class="first">
<a href="#">Lobortis fringilla dictum cras</a>
</li>
<li>
<a href="#">Erat primis accumsan facilisis</a>
</li>
<li>
<a href="#">Laoreet in in magna</a>
</li>
<li>
<a href="#">Porta a vulputate placerat</a>
</li>
<li class="last">
<a href="#">Neque rhoncus rhoncus iaculis</a>
</li>
</ul>
</div>
<br class="clear" />
</div>
<br class="clear" />
</div>
</div>
<div id="copyright">
&copy; Your Site Name | Design: <a href="http://templated.org/free-css-templates/coffeelike/">Coffeelike</a> by <a href="http://nodethirtythree.com">nodethirtythree</a> + <a href="http://templated.org/">Templated.org</a>
</div>
</div>
</body>
</html>

0 comments on commit 8ccfd62

Please sign in to comment.