public static IApplicationBuilder UseJwtSimpleServer(this IApplicationBuilder app, Action <JwtSimpleServerOptions> serverSetup)
        {
            var simpleServerOptions = new JwtSimpleServerOptions();

            serverSetup(simpleServerOptions);

            if (string.IsNullOrEmpty(simpleServerOptions.IssuerSigningKey))
            {
                throw new ArgumentNullException(nameof(JwtSimpleServerOptions.IssuerSigningKey));
            }

            app.MapWhen(context => IsValidJwtMiddlewareRequest(context, simpleServerOptions),
                        appBuilder => appBuilder.UseMiddleware <JwtSimpleServerMiddleware>(simpleServerOptions));

            app.UseAuthentication();
            return(app);
        }
 private static bool IsValidJwtMiddlewareRequest(HttpContext context, JwtSimpleServerOptions options)
 {
     return(context.Request.Method == HttpMethods.Post &&
            context.Request.ContentType == XFormUrlEncoded &&
            context.Request.Path == options.Path);
 }