Skip to content

Instantly share code, notes, and snippets.

View simonhdickson's full-sized avatar

Simon Dickson simonhdickson

View GitHub Profile

Keybase proof

I hereby claim:

  • I am simonhdickson on github.
  • I am simonhdickson (https://keybase.io/simonhdickson) on keybase.
  • I have a public key ASCse-S5cVnTAWCZ7cJ3Sy2lpefTh3cd2z9hbZEkoG7Y2Qo

To claim this, I am signing this object:

@simonhdickson
simonhdickson / TokenValidationAttribute.cs
Last active March 21, 2017 16:43
Using a facebook token to authenticate your web api
public class TokenValidationAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(HttpActionContext actionContext)
{
var token = actionContext.Request.Headers.GetValues("Token").First();
if (this.IsTokenValid(token))
{
base.OnActionExecuting(actionContext);
return;
}
let (|MyPattern|_|) (|Number|_|) = function
| Number 1 -> Some MyPattern
| _ -> None
let doSomething = function 1 -> Some 1 | _ -> None
match 1 with
| MyPattern doSomething -> ()
| _ -> ()