initial commit

This commit is contained in:
Chris Sexton 2019-10-05 09:54:15 -04:00
commit 028ee0bf10
14 changed files with 956 additions and 0 deletions

598
.gitignore vendored Normal file
View File

@ -0,0 +1,598 @@
# Created by https://www.gitignore.io/api/vim,osx,visualstudiocode,visualstudio,dotnetcore,windows,linux
# Edit at https://www.gitignore.io/?templates=vim,osx,visualstudiocode,visualstudio,dotnetcore,windows,linux
### DotnetCore ###
# .NET Core build folders
/bin
/obj
# Common node modules locations
/node_modules
/wwwroot/node_modules
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### OSX ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Vim ###
# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
# Session
Session.vim
Sessionx.vim
# Temporary
.netrwhist
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~
### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
### VisualStudio ###
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# End of https://www.gitignore.io/api/vim,osx,visualstudiocode,visualstudio,dotnetcore,windows,linux
#
#
# Created by https://www.gitignore.io/api/rider,intellij+all
# Edit at https://www.gitignore.io/?templates=rider,intellij+all
### Intellij+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### Intellij+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
.idea/
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
*.iml
modules.xml
.idea/misc.xml
*.ipr
# Sonarlint plugin
.idea/sonarlint
### Rider ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
# Generated files
# Sensitive or high-churn files
# Gradle
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
# Mongo Explorer plugin
# File-based project format
# IntelliJ
# mpeltonen/sbt-idea plugin
# JIRA plugin
# Cursive Clojure plugin
# Crashlytics plugin (for Android Studio and IntelliJ)
# Editor-based Rest Client
# Android studio 3.1+ serialized cache file
# End of https://www.gitignore.io/api/rider,intellij+all

31
README.md Normal file
View File

@ -0,0 +1,31 @@
# Server
A [Giraffe](https://github.com/giraffe-fsharp/Giraffe) web application, which has been created via the `dotnet new giraffe` command.
## Build and test the application
### Windows
Run the `build.bat` script in order to restore, build and test (if you've selected to include tests) the application:
```
> ./build.bat
```
### Linux/macOS
Run the `build.sh` script in order to restore, build and test (if you've selected to include tests) the application:
```
$ ./build.sh
```
## Run the application
After a successful build you can start the web application by executing the following command in your terminal:
```
dotnet run src/Server
```
After the application has started visit [http://localhost:5000](http://localhost:5000) in your preferred browser.

62
Server.sln Normal file
View File

@ -0,0 +1,62 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Server", "src\Server\Server.fsproj", "{6D05B808-2DE2-4BD7-A0B5-5FAB1483C73E}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Game", "src\Game\Game.fsproj", "{112878D4-EA25-4D0F-8E89-98D66AA68D22}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "GameTest", "src\GameTest\GameTest.fsproj", "{D3352585-8447-43BB-8189-44C562D8DCE6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6D05B808-2DE2-4BD7-A0B5-5FAB1483C73E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D05B808-2DE2-4BD7-A0B5-5FAB1483C73E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D05B808-2DE2-4BD7-A0B5-5FAB1483C73E}.Debug|x64.ActiveCfg = Debug|Any CPU
{6D05B808-2DE2-4BD7-A0B5-5FAB1483C73E}.Debug|x64.Build.0 = Debug|Any CPU
{6D05B808-2DE2-4BD7-A0B5-5FAB1483C73E}.Debug|x86.ActiveCfg = Debug|Any CPU
{6D05B808-2DE2-4BD7-A0B5-5FAB1483C73E}.Debug|x86.Build.0 = Debug|Any CPU
{6D05B808-2DE2-4BD7-A0B5-5FAB1483C73E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D05B808-2DE2-4BD7-A0B5-5FAB1483C73E}.Release|Any CPU.Build.0 = Release|Any CPU
{6D05B808-2DE2-4BD7-A0B5-5FAB1483C73E}.Release|x64.ActiveCfg = Release|Any CPU
{6D05B808-2DE2-4BD7-A0B5-5FAB1483C73E}.Release|x64.Build.0 = Release|Any CPU
{6D05B808-2DE2-4BD7-A0B5-5FAB1483C73E}.Release|x86.ActiveCfg = Release|Any CPU
{6D05B808-2DE2-4BD7-A0B5-5FAB1483C73E}.Release|x86.Build.0 = Release|Any CPU
{112878D4-EA25-4D0F-8E89-98D66AA68D22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{112878D4-EA25-4D0F-8E89-98D66AA68D22}.Debug|Any CPU.Build.0 = Debug|Any CPU
{112878D4-EA25-4D0F-8E89-98D66AA68D22}.Debug|x64.ActiveCfg = Debug|Any CPU
{112878D4-EA25-4D0F-8E89-98D66AA68D22}.Debug|x64.Build.0 = Debug|Any CPU
{112878D4-EA25-4D0F-8E89-98D66AA68D22}.Debug|x86.ActiveCfg = Debug|Any CPU
{112878D4-EA25-4D0F-8E89-98D66AA68D22}.Debug|x86.Build.0 = Debug|Any CPU
{112878D4-EA25-4D0F-8E89-98D66AA68D22}.Release|Any CPU.ActiveCfg = Release|Any CPU
{112878D4-EA25-4D0F-8E89-98D66AA68D22}.Release|Any CPU.Build.0 = Release|Any CPU
{112878D4-EA25-4D0F-8E89-98D66AA68D22}.Release|x64.ActiveCfg = Release|Any CPU
{112878D4-EA25-4D0F-8E89-98D66AA68D22}.Release|x64.Build.0 = Release|Any CPU
{112878D4-EA25-4D0F-8E89-98D66AA68D22}.Release|x86.ActiveCfg = Release|Any CPU
{112878D4-EA25-4D0F-8E89-98D66AA68D22}.Release|x86.Build.0 = Release|Any CPU
{D3352585-8447-43BB-8189-44C562D8DCE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3352585-8447-43BB-8189-44C562D8DCE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D3352585-8447-43BB-8189-44C562D8DCE6}.Debug|x64.ActiveCfg = Debug|Any CPU
{D3352585-8447-43BB-8189-44C562D8DCE6}.Debug|x64.Build.0 = Debug|Any CPU
{D3352585-8447-43BB-8189-44C562D8DCE6}.Debug|x86.ActiveCfg = Debug|Any CPU
{D3352585-8447-43BB-8189-44C562D8DCE6}.Debug|x86.Build.0 = Debug|Any CPU
{D3352585-8447-43BB-8189-44C562D8DCE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3352585-8447-43BB-8189-44C562D8DCE6}.Release|Any CPU.Build.0 = Release|Any CPU
{D3352585-8447-43BB-8189-44C562D8DCE6}.Release|x64.ActiveCfg = Release|Any CPU
{D3352585-8447-43BB-8189-44C562D8DCE6}.Release|x64.Build.0 = Release|Any CPU
{D3352585-8447-43BB-8189-44C562D8DCE6}.Release|x86.ActiveCfg = Release|Any CPU
{D3352585-8447-43BB-8189-44C562D8DCE6}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

3
build.bat Normal file
View File

@ -0,0 +1,3 @@
dotnet restore src/Server
dotnet build src/Server

4
build.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
dotnet restore src/Server
dotnet build src/Server

11
src/Game/Game.fsproj Normal file
View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Library.fs"/>
</ItemGroup>
</Project>

26
src/Game/Library.fs Normal file
View File

@ -0,0 +1,26 @@
module Game.Game
type direction =
| NS
| EW
| Corner
type env =
| Wall of direction
| Floor
| Trap
let envToString e =
match e with
| Wall d ->
match d with
| NS -> "|"
| EW -> "-"
| Corner -> "+"
| Floor -> "#"
| Trap -> "!"
let rowToString = List.fold (fun r e -> r + envToString e) ""
let floorToString = List.fold (fun f r -> f + rowToString r + "\n") ""

View File

@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<IsPackable>false</IsPackable>
<GenerateProgramFile>false</GenerateProgramFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="UnitTest1.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Game\Game.fsproj" />
</ItemGroup>
</Project>

1
src/GameTest/Program.fs Normal file
View File

@ -0,0 +1 @@
module Program = let [<EntryPoint>] main _ = 0

19
src/GameTest/UnitTest1.fs Normal file
View File

@ -0,0 +1,19 @@
module GameTest
open NUnit.Framework
open Game.Game
[<SetUp>]
let Setup () =
()
[<Test>]
let TestFloorToString() =
let floor = [
[ Wall Corner; Wall EW; Wall Corner ];
[ Wall NS; Floor; Wall NS ];
[ Wall Corner; Wall EW; Wall Corner ]
]
let actual = floorToString floor
let expected = "+-+\n|#|\n+-+\n"
Assert.AreEqual(actual, expected)

124
src/Server/Program.fs Normal file
View File

@ -0,0 +1,124 @@
module Server.App
open System
open System.IO
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Cors.Infrastructure
open Microsoft.AspNetCore.Hosting
open Microsoft.Extensions.Logging
open Microsoft.Extensions.DependencyInjection
open Giraffe
open Game.Game
// ---------------------------------
// Models
// ---------------------------------
type Message =
{
Text : string
}
// ---------------------------------
// Views
// ---------------------------------
module Views =
open GiraffeViewEngine
let layout (content: XmlNode list) =
html [] [
head [] [
title [] [ encodedText "Server" ]
link [ _rel "stylesheet"
_type "text/css"
_href "/main.css" ]
]
body [] content
]
let partial () =
h1 [] [ encodedText "Server" ]
let index (model : Message) =
[
partial()
pre [] [ encodedText model.Text ]
] |> layout
// ---------------------------------
// Web app
// ---------------------------------
let indexHandler (name : string) =
let floor = [
[ Wall Corner; Wall EW; Wall Corner ];
[ Wall NS; Floor; Wall NS ];
[ Wall Corner; Wall EW; Wall Corner ]
]
let model = { Text = floorToString floor }
let view = Views.index model
htmlView view
let webApp =
choose [
GET >=>
choose [
route "/" >=> indexHandler "world"
routef "/hello/%s" indexHandler
]
setStatusCode 404 >=> text "Not Found" ]
// ---------------------------------
// Error handler
// ---------------------------------
let errorHandler (ex : Exception) (logger : ILogger) =
logger.LogError(ex, "An unhandled exception has occurred while executing the request.")
clearResponse >=> setStatusCode 500 >=> text ex.Message
// ---------------------------------
// Config and Main
// ---------------------------------
let configureCors (builder : CorsPolicyBuilder) =
builder.WithOrigins("http://localhost:8080")
.AllowAnyMethod()
.AllowAnyHeader()
|> ignore
let configureApp (app : IApplicationBuilder) =
let env = app.ApplicationServices.GetService<IHostingEnvironment>()
(match env.IsDevelopment() with
| true -> app.UseDeveloperExceptionPage()
| false -> app.UseGiraffeErrorHandler errorHandler)
.UseHttpsRedirection()
.UseCors(configureCors)
.UseStaticFiles()
.UseGiraffe(webApp)
let configureServices (services : IServiceCollection) =
services.AddCors() |> ignore
services.AddGiraffe() |> ignore
let configureLogging (builder : ILoggingBuilder) =
builder.AddFilter(fun l -> l.Equals LogLevel.Error)
.AddConsole()
.AddDebug() |> ignore
[<EntryPoint>]
let main _ =
let contentRoot = Directory.GetCurrentDirectory()
let webRoot = Path.Combine(contentRoot, "WebRoot")
WebHostBuilder()
.UseKestrel()
.UseContentRoot(contentRoot)
.UseIISIntegration()
.UseWebRoot(webRoot)
.Configure(Action<IApplicationBuilder> configureApp)
.ConfigureServices(configureServices)
.ConfigureLogging(configureLogging)
.Build()
.Run()
0

33
src/Server/Server.fsproj Normal file
View File

@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<DebugType>portable</DebugType>
<AssemblyName>Server</AssemblyName>
<OutputType>Exe</OutputType>
<EnableDefaultContentItems>false</EnableDefaultContentItems>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.*" />
<PackageReference Include="Giraffe" Version="3.4.*" />
<PackageReference Include="TaskBuilder.fs" Version="2.1.*" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<None Include="web.config" CopyToOutputDirectory="PreserveNewest" />
<Content Include="WebRoot\**\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Game\Game.fsproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,10 @@
body {
font-family: Arial, Helvetica, sans-serif;
color: #333;
font-size: .9em;
}
h1 {
font-size: 1.5em;
color: #334499;
}

9
src/Server/web.config Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments="Server.dll" stdoutLogEnabled="false" stdoutLogFile="logs/stdout" />
</system.webServer>
</configuration>