コード例 #1
0
        /// <summary>
        /// Sets up HTTP methods mappings.
        /// </summary>
        /// <param name="service">Service handling requests</param>
        public DefaultModule(DefaultService service) : base("/")
        {
            Post["/authenticate"] = parameters =>
            {
                var authenticationRequest = this.Bind <AuthenticationRequest>();
                Preconditions.IsNotNull(authenticationRequest, "Required parameter: 'authenticationRequest' is missing at 'Authenticate'");

                return(service.Authenticate(Context, authenticationRequest));
            };

            Post["/invalidate"] = parameters =>
            {
                var accessKeys = this.Bind <AccessKeys>();
                Preconditions.IsNotNull(accessKeys, "Required parameter: 'accessKeys' is missing at 'Invalidate'");

                service.Invalidate(Context, accessKeys);
                return(new Response {
                    ContentType = "application/json"
                });
            };

            Post["/refresh"] = parameters =>
            {
                var refreshRequest = this.Bind <RefreshRequest>();
                Preconditions.IsNotNull(refreshRequest, "Required parameter: 'refreshRequest' is missing at 'Refresh'");

                return(service.Refresh(Context, refreshRequest));
            };

            Post["/signout"] = parameters =>
            {
                var usernamePassword = this.Bind <UsernamePassword>();
                Preconditions.IsNotNull(usernamePassword, "Required parameter: 'usernamePassword' is missing at 'Siginout'");

                service.Siginout(Context, usernamePassword);
                return(new Response {
                    ContentType = "application/json"
                });
            };

            Post["/validate"] = parameters =>
            {
                var accessKeys = this.Bind <AccessKeys>();
                Preconditions.IsNotNull(accessKeys, "Required parameter: 'accessKeys' is missing at 'Validate'");

                service.Validate(Context, accessKeys);
                return(new Response {
                    ContentType = "application/json"
                });
            };
        }