コード例 #1
0
        public ResttpComponent(AppFunc next, ResttpConfiguration config)
        {
            _next = next;
            Config = config;

            //TestRoutes(new HttpRouteResolver(Config.HttpRoutes));
        }
コード例 #2
0
ファイル: Startup.cs プロジェクト: dovydasvenckus/Resttp
    public void Configuration(IAppBuilder app)
    {
        var config = new ResttpConfiguration(typeof(HomeController).Assembly);
        config.MapHttpRoutesFromAttributes();
        config.HttpRoutes.AddRoutes
            (
            "Home",
            "/Main",
            new
            {
                controller = "Home",
                action = "Index",
                httpMethod = "Get"
            });
        config.HttpRoutes.AddRoutes
            (
            "Home",
            "/{controller}/{action}",
            new
            {
                controller = "Home"
            });

        config.DependencyResolver = GetResolver();
        app.UseResttp(config);
    }
コード例 #3
0
        public static void UseResttp(this IAppBuilder app, ResttpConfiguration config)
        {
            if (app == null)
            {
                throw new ArgumentNullException("app");
            }

            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            app.Use<RoutingComponent>(new HttpRouteResolver(config.HttpRoutes));
            app.Use<ControlerCreatorComponent>(config.DependencyResolver, config.ControllersAssembly);
            app.Use<ActionInvokerComponent>(config.Formatters, config.ContentNegotiator, config.ActionParameterBinder);
        }