Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dotnet-websharper/owin
Wrappers for hosting WebSharper sitelets and remoting components in OWIN projects
https://github.com/dotnet-websharper/owin
Last synced: about 2 months ago
JSON representation
Wrappers for hosting WebSharper sitelets and remoting components in OWIN projects
- Host: GitHub
- URL: https://github.com/dotnet-websharper/owin
- Owner: dotnet-websharper
- License: apache-2.0
- Created: 2014-11-11T10:25:47.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-06-17T05:23:49.000Z (over 1 year ago)
- Last Synced: 2024-10-07T15:04:39.119Z (3 months ago)
- Language: C#
- Size: 406 KB
- Stars: 10
- Watchers: 6
- Forks: 9
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-websharper - Owin - OWIN defines a standard interface between .NET web servers and web applications. This library allows hosting WebSharper applications on any OWIN-compliant host - ASP.NET, Katana, Suave, etc. (Libraries / Server-side hosting)
README
# Overview
This library allows you to run a [WebSharper](http://websharper.com)
Sitelet application through an [OWIN](http://owin.org/) interface,
version 1.0. In the terminology of [the OWIN
specification](http://owin.org/spec/spec/owin-1.0.0.html), WebSharper
is a Web Framework and WebSharper.Owin is an adapter layer for it.After adding the reference to the project all the classes can be found
under the `WebSharper.Owin` module.# Usage
WebSharper.Owin provides its functionality through several extension
methods on the `IAppBuilder` type. They are the following:```fsharp
UseDiscoveredSitelet : webRoot: string -> IAppBuilder
```Inspects the `webRoot` folder, looking for an assembly in the `bin`
subfolder that contains a WebSharper Sitelet, and runs this Sitelet
with `webRoot` as the root folder.```fsharp
UseSitelet : webRoot: string * Sitelet<'T> -> IAppBuilder
```Runs the provided Sitelet with `webRoot` as the root folder, using
WebSharper metadata loaded from assemblies located in the `bin`
subfolder of `webRoot`.```fsharp
UseCustomSitelet : Options * Sitelet<'T> -> IAppBuilder
```Runs the provided Sitelet. Allows a more customized setup than the
previous methods, for example running a Sitelet whose code isn't
located in the `bin` subfolder of the root folder, or running the
Sitelet with a URL prefix.```fsharp
UseWebSharperRemoting : webRoot: string -> IAppBuilder
```Runs the WebSharper Remoting service, allowing WebSharper-compiled
client-side code to invoke `[]`-annotated server-side functions.
Note that the Remoting service is automatically run by the above
methods `UseDiscoveredSitelet` and `UseSitelet`, as well as
`UseCustomSitelet` if `options.RunRemoting` is set to `true`.# Notes
This library does not take care of serving the files extracted from
WebSharper assemblies, such as the generated JavaScript files, from
the file system. You need to use a static files middleware. The
example self-hosted Sitelet application uses a middleware available
from NuGet as `Microsoft.Owin.StaticFiles`, as follows:```fsharp
open global.Owin
open Microsoft.Owin.StaticFiles
open Microsoft.Owin.FileSystems
open WebSharper.Owinlet RunSitelet (appB: IAppBuilder) mySitelet rootFolder =
appB.UseStaticFiles(
StaticFileOptions(
FileSystem = PhysicalFileSystem(rootFolder)))
.UseSitelet(rootFolder, mySitelet)
```