<commit_before># ASP.NET Core Lambda

A functional ASP.NET Core micro framework for building rich web applications.

[![Build status](https://ci.appveyor.com/api/projects/status/0ft2427dflip7wti/branch/master?svg=true)](https://ci.appveyor.com/project/dustinmoris/aspnetcore-lambda/branch/master)
[![NuGet Info](https://buildstats.info/nuget/AspNetCore.Lambda?includePreReleases=true)](https://www.nuget.org/packages/AspNetCore.Lambda/)

[![Build history](https://buildstats.info/appveyor/chart/dustinmoris/aspnetcore-lambda)](https://ci.appveyor.com/project/dustinmoris/aspnetcore-lambda/history)

**ATTENTION: THIS PROJECT IS STILL WORK IN PROGRESS**

## Table of contents

- [About](#about)
- [Basics](#basics)
    - [HttpHandler](#httphandler)
    - [Combinators](#combinators)
        - [bind (>>=)](#bind-)
        - [choose](#choose)
- [Default HttpHandlers](#default-httphandlers)
    - [choose](#choose)
    - [GET, POST, PUT, PATCH, DELETE](#get-post-put-patch-delete)
    - [mustAccept](#mustaccept)
    - [route](#route)
    - [routef](#routef)
    - [routeci](#routeci)
    - [routecif](#routecif)
    - [routeStartsWith](#routestartswith)
    - [routeStartsWithCi](#routestartswithci)
    - [setStatusCode](#setstatuscode)
    - [setHttpHeader](#sethttpheader)
    - [setBody](#setbody)
    - [setBodyAsString](#setbodyasstring)
    - [text](#text)
    - [json](#json)
    - [dotLiquid](#dotliquid)
    - [htmlTemplate](#htmltemplate)
    - [htmlFile](#htmlfile)
- [Custom HttpHandlers](#custom-httphandlers)
- [Installation](#installation)
- [License](#license)
- [Contribution](#contribution)

## About

ASP.NET Core Lambda is an F# web framework similar to Suave, but has been designed with ASP.NET Core in mind and can be plugged into the ASP.NET Core pipeline via middleware. ASP.NET Core Lambda has been heavily inspired by Suave and its concept of web parts and the ability to compose many smaller web parts into a large web application.

### Who is it for?

ASP.NET Core Lambda is intended for developers who want to build rich web applications on top of ASP.NET Core in a functional first approach. ASP.NET Core is a powerfull web platform with Microsoft and a big community behind it and ASP.NET Core Lambda is designed for F# developers who want to benefit from that eco system.

It is designed to be as lean as possible and to extend ASP.NET Core only where there's a lack for functional programmers instead of re-inventing the entire platform from scratch. It's mentality is to stand on top of the shoulders of a strong platform and re-use the existing ASP.NET Core building blocks where possible.

## Basics

### HttpHandler

The only building block in ASP.NET Core Lambda is a so called `HttpHandler`:

```
type HttpHandlerContext =
    {
        HttpContext  : HttpContext
        Environment  : IHostingEnvironment
        Logger       : ILogger
    }

type HttpHandler = HttpHandlerContext -> Async<HttpHandlerContext option>
```

A `HttpHandler` is a simple function which takes in a `HttpHandlerContext` and returns an object of the same type when finished.

Inside that function it can process an incoming `HttpRequest` and make changes to the `HttpResponse` of the given `HttpContext`. By receiving and returning a `HttpContext` there's nothing which cannot be done from inside a `HttpHandler`.

A `HttpHandler` can decide to not further process an incoming request and return `None` instead. In this case another `HttpHandler` might continue processing the request or the middleware will simply defer to the next `RequestDelegate` in the ASP.NET Core pipeline.

### Combinators

#### bind (>>=)
<commit_msg>More readme changes<commit_after># ASP.NET Core Lambda

A functional ASP.NET Core micro framework for building rich web applications.

[![Build status](https://ci.appveyor.com/api/projects/status/0ft2427dflip7wti/branch/master?svg=true)](https://ci.appveyor.com/project/dustinmoris/aspnetcore-lambda/branch/master)
[![NuGet Info](https://buildstats.info/nuget/AspNetCore.Lambda?includePreReleases=true)](https://www.nuget.org/packages/AspNetCore.Lambda/)

[![Build history](https://buildstats.info/appveyor/chart/dustinmoris/aspnetcore-lambda)](https://ci.appveyor.com/project/dustinmoris/aspnetcore-lambda/history)

**ATTENTION: THIS PROJECT IS STILL WORK IN PROGRESS**

## Table of contents

- [About](#about)
- [Basics](#basics)
    - [HttpHandler](#httphandler)
    - [Combinators](#combinators)
        - [bind (>>=)](#bind-)
        - [choose](#choose)
- [Default HttpHandlers](#default-httphandlers)
    - [choose](#choose)
    - [GET, POST, PUT, PATCH, DELETE](#get-post-put-patch-delete)
    - [mustAccept](#mustaccept)
    - [route](#route)
    - [routef](#routef)
    - [routeci](#routeci)
    - [routecif](#routecif)
    - [routeStartsWith](#routestartswith)
    - [routeStartsWithCi](#routestartswithci)
    - [setStatusCode](#setstatuscode)
    - [setHttpHeader](#sethttpheader)
    - [setBody](#setbody)
    - [setBodyAsString](#setbodyasstring)
    - [text](#text)
    - [json](#json)
    - [dotLiquid](#dotliquid)
    - [htmlTemplate](#htmltemplate)
    - [htmlFile](#htmlfile)
- [Custom HttpHandlers](#custom-httphandlers)
- [Installation](#installation)
- [License](#license)
- [Contribution](#contribution)

## About

ASP.NET Core Lambda is an F# web framework similar to Suave, but has been designed with [ASP.NET Core](https://www.asp.net/core) in mind and can be plugged into the ASP.NET Core pipeline via [middleware](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/middleware). ASP.NET Core Lambda has been heavily inspired by [Suave](https://suave.io/) and its concept of web parts and the ability to compose many smaller web parts into a large web application.

### Who is it for?

ASP.NET Core Lambda is intended for developers who want to build rich web applications on top of ASP.NET Core in a functional first approach. ASP.NET Core is a powerful web platform, which has Microsoft and a huge developer community behind it and ASP.NET Core Lambda is designed for F# developers who want to benefit from that eco system.

It is designed to be as lean as possible and to extend ASP.NET Core only where there's a lack for functional programmers today instead of re-inventing the entire platform from scratch. It's mentality is to stand on top of the shoulders of a giant and re-use the existing ASP.NET Core building blocks as much as possible.

You can think of it as an equivalent of the MVC framework, but for functional developers.

## Basics

### HttpHandler

The only building block in ASP.NET Core Lambda is a so called `HttpHandler`:

```
type HttpHandlerContext =
    {
        HttpContext  : HttpContext
        Environment  : IHostingEnvironment
        Logger       : ILogger
    }

type HttpHandler = HttpHandlerContext -> Async<HttpHandlerContext option>
```

A `HttpHandler` is a simple function which takes in a `HttpHandlerContext` and returns an object of the same type when finished.

Inside that function it can process an incoming `HttpRequest` and make changes to the `HttpResponse` of the given `HttpContext`. By receiving and returning a `HttpContext` there's nothing which cannot be done from inside a `HttpHandler`.

A `HttpHandler` can decide to not further process an incoming request and return `None` instead. In this case another `HttpHandler` might continue processing the request or the middleware will simply defer to the next `RequestDelegate` in the ASP.NET Core pipeline.

### Combinators

#### bind (>>=)

{'fraction_non_alphanumeric': 0.10806858965838097, 'fraction_numerical': 0.0015951083344410474, 'mean_word_length': 4.291139240506329, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 15, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6900666', 'n_tokens_mistral': 2306, 'n_tokens_neox': 2137, 'n_words': 762}