Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
TourDataManager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill
TourDataManager
Commits
ef940813
Commit
ef940813
authored
Oct 17, 2018
by
Kirill
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Проект с Nancy
parent
d3bb78b0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
171 additions
and
0 deletions
+171
-0
Program.cs
Rest/Program.cs
+63
-0
AssemblyInfo.cs
Rest/Properties/AssemblyInfo.cs
+35
-0
Rest.csproj
Rest/Rest.csproj
+67
-0
packages.config
Rest/packages.config
+6
-0
No files found.
Rest/Program.cs
0 → 100644
View file @
ef940813
using
System
;
using
System.Text
;
using
System.Threading.Tasks
;
using
Nancy
;
using
Nancy.ErrorHandling
;
using
Nancy.Hosting.Self
;
namespace
Rest
{
internal
class
Program
{
public
static
void
Main
(
string
[]
args
){
var
hostConfigs
=
new
HostConfiguration
{
UrlReservations
=
new
UrlReservations
{
CreateAutomatically
=
true
}
};
// initialize an instance of NancyHost (found in the Nancy.Hosting.Self package)
var
host
=
new
NancyHost
(
hostConfigs
,
new
Uri
(
"http://localhost:12345"
));
host
.
Start
();
// start hosting
Console
.
ReadKey
();
host
.
Stop
();
// stop hosting
}
}
public
class
Module
:
NancyModule
{
public
Module
()
{
Get
(
"/greet/{name}"
,
x
=>
{
return
string
.
Concat
(
"Hello "
,
x
.
name
);
});
Get
(
"/async"
,
async
_
=>
{
await
Task
.
Delay
(
TimeSpan
.
FromSeconds
(
3
));
return
"Done"
;
});
}
}
// Кастомное 404
public
class
StatusCodeHandler
:
IStatusCodeHandler
{
private
readonly
IRootPathProvider
_rootPathProvider
;
public
StatusCodeHandler
(
IRootPathProvider
rootPathProvider
)
{
_rootPathProvider
=
rootPathProvider
;
}
// The HandleStatusCode() method checks if status code is HttpStatusCode.NotFound. Returning true tells Nancy that our StatusCodeHandler will handle the response to this status code.
public
bool
HandlesStatusCode
(
HttpStatusCode
statusCode
,
NancyContext
context
)
{
return
statusCode
==
HttpStatusCode
.
NotFound
;
}
public
void
Handle
(
HttpStatusCode
statusCode
,
NancyContext
context
)
{
var
response
=
(
Response
)
@"{""message"": ""404 :(""}"
;
response
.
ContentType
=
"application/json"
;
context
.
Response
=
response
;
}
}
}
\ No newline at end of file
Rest/Properties/AssemblyInfo.cs
0 → 100644
View file @
ef940813
using
System.Reflection
;
using
System.Runtime.InteropServices
;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Rest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Rest")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("6708BCDF-A4C5-4D48-95A4-5C51B4C140B9")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
\ No newline at end of file
Rest/Rest.csproj
0 → 100644
View file @
ef940813
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"4.0"
DefaultTargets=
"Build"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<Import
Project=
"$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition=
"Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"
/>
<PropertyGroup>
<Configuration
Condition=
" '$(Configuration)' == '' "
>
Debug
</Configuration>
<Platform
Condition=
" '$(Platform)' == '' "
>
AnyCPU
</Platform>
<ProjectGuid>
{6708BCDF-A4C5-4D48-95A4-5C51B4C140B9}
</ProjectGuid>
<OutputType>
Exe
</OutputType>
<AppDesignerFolder>
Properties
</AppDesignerFolder>
<RootNamespace>
Rest
</RootNamespace>
<AssemblyName>
Rest
</AssemblyName>
<TargetFrameworkVersion>
v4.5.2
</TargetFrameworkVersion>
<FileAlignment>
512
</FileAlignment>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "
>
<PlatformTarget>
AnyCPU
</PlatformTarget>
<DebugSymbols>
true
</DebugSymbols>
<DebugType>
full
</DebugType>
<Optimize>
false
</Optimize>
<OutputPath>
bin\Debug\
</OutputPath>
<DefineConstants>
DEBUG;TRACE
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "
>
<PlatformTarget>
AnyCPU
</PlatformTarget>
<DebugType>
pdbonly
</DebugType>
<Optimize>
true
</Optimize>
<OutputPath>
bin\Release\
</OutputPath>
<DefineConstants>
TRACE
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"Microsoft.CSharp"
/>
<Reference
Include=
"Nancy, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
>
<HintPath>
..\packages\Nancy.2.0.0-clinteastwood\lib\net452\Nancy.dll
</HintPath>
<Private>
True
</Private>
</Reference>
<Reference
Include=
"Nancy.Hosting.Self, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
>
<HintPath>
..\packages\Nancy.Hosting.Self.2.0.0-clinteastwood\lib\net452\Nancy.Hosting.Self.dll
</HintPath>
<Private>
True
</Private>
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Core"
/>
<Reference
Include=
"System.Data"
/>
<Reference
Include=
"System.Xml"
/>
</ItemGroup>
<ItemGroup>
<Compile
Include=
"Program.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
</ItemGroup>
<ItemGroup>
<None
Include=
"packages.config"
/>
</ItemGroup>
<ItemGroup>
<Analyzer
Include=
"..\packages\AsyncUsageAnalyzers.1.0.0-alpha003\analyzers\dotnet\AsyncUsageAnalyzers.dll"
/>
</ItemGroup>
<Import
Project=
"$(MSBuildToolsPath)\Microsoft.CSharp.targets"
/>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
Rest/packages.config
0 → 100644
View file @
ef940813
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"AsyncUsageAnalyzers"
version
=
"1.0.0-alpha003"
targetFramework
=
"net452"
developmentDependency
=
"true"
/>
<
package
id
=
"Nancy"
version
=
"2.0.0-clinteastwood"
targetFramework
=
"net452"
/>
<
package
id
=
"Nancy.Hosting.Self"
version
=
"2.0.0-clinteastwood"
targetFramework
=
"net452"
/>
</
packages
>
\ No newline at end of file
Kirill
@Nobi
mentioned in issue
#6 (closed)
·
Oct 17, 2018
mentioned in issue
#6 (closed)
mentioned in issue #6
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment