public override string HandleGet()
        {
            var sb = new System.Text.StringBuilder("<!DOCTYPE html><html><body>");

            var sb_api = new System.Text.StringBuilder();
            var sb_sdk = new System.Text.StringBuilder();

            sb_api.AppendLine("<p>API<br>");
            var endpoints = EndPointDictionary.GetDictionary().Values;
            int i         = 1;

            foreach (var endpoint in endpoints)
            {
                if (endpoint is CSharpSdkEndPoint)
                {
                    sb_sdk.AppendLine($" <a href=\"/{endpoint.Path}\">C# SDK</a><BR>");
                    continue;
                }
                if (!(endpoint is HomePageEndPoint))
                {
                    sb_api.AppendLine((i++).ToString() + $" <a href=\"/{endpoint.Path}\">{endpoint.Path}</a><BR>");
                }
            }


            sb.Append(sb_sdk);
            sb.Append(sb_api);
            sb.AppendLine("</p></body></html>");
            return(sb.ToString());
        }
        public static EndPoint Get(string path)
        {
            if (path.StartsWith("/"))
            {
                path = path.Substring(1);
            }
            var      dict = EndPointDictionary.GetDictionary();
            EndPoint rc   = null;

            dict.TryGetValue(path.ToLowerInvariant(), out rc);
            return(rc);
        }
        public RhinoModule()
        {
            Get["/healthcheck"] = _ => "healthy";

            var endpoints = EndPointDictionary.GetDictionary();

            foreach (var kv in endpoints)
            {
                Get[kv.Key] = _ =>
                {
                    if (NancySelfHost.RunningHttps && !Request.Url.IsSecure)
                    {
                        string url = Request.Url.ToString().Replace("http", "https");
                        return(new Nancy.Responses.RedirectResponse(url, Nancy.Responses.RedirectResponse.RedirectType.Permanent));
                    }
                    Logger.WriteInfo($"GET {kv.Key}", null);
                    var response = kv.Value.HandleGetAsResponse();
                    if (response != null)
                    {
                        return(response);
                    }
                    return(kv.Value.HandleGet());
                };
                Post[kv.Key] = _ =>
                {
                    if (NancySelfHost.RunningHttps && !Request.Url.IsSecure)
                    {
                        return(Nancy.HttpStatusCode.HttpVersionNotSupported);
                    }

                    Logger.WriteInfo($"POST {kv.Key}", GetApiToken());
                    if (!string.IsNullOrWhiteSpace(kv.Key) && kv.Key.Length > 1)
                    {
                        var authCheck = CheckAuthorization();
                        if (authCheck != Nancy.HttpStatusCode.OK)
                        {
                            return(authCheck);
                        }
                    }
                    var jsonString = Request.Body.AsString();

                    // In order to enable CORS, we add the proper headers to the response
                    var resp = new Nancy.Response();
                    resp.Headers.Add("Access-Control-Allow-Origin", "*");
                    resp.Headers.Add("Access-Control-Allow-Methods", "POST,GET");
                    resp.Headers.Add("Access-Control-Allow-Headers", "Accept, Origin, Content-type");
                    resp.Contents = (e) =>
                    {
                        using (var sw = new System.IO.StreamWriter(e))
                        {
                            bool multiple = false;
                            System.Collections.Generic.Dictionary <string, string> returnModifiers = null;
                            foreach (string name in Request.Query)
                            {
                                if (name.StartsWith("return.", StringComparison.InvariantCultureIgnoreCase))
                                {
                                    if (returnModifiers == null)
                                    {
                                        returnModifiers = new System.Collections.Generic.Dictionary <string, string>();
                                    }
                                    string dataType = "Rhino.Geometry." + name.Substring("return.".Length);
                                    string items    = Request.Query[name];
                                    returnModifiers[dataType] = items;
                                    continue;
                                }
                                if (name.Equals("multiple", StringComparison.InvariantCultureIgnoreCase))
                                {
                                    multiple = Request.Query[name];
                                }
                            }
                            var postResult = kv.Value.HandlePost(jsonString, multiple, returnModifiers);
                            sw.Write(postResult);
                            sw.Flush();
                        }
                    };
                    return(resp);
                };
            }
        }