GithubHelp home page GithubHelp logo

tempbottle / rustymvc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from earlz/rustymvc

0.0 2.0 0.0 219 KB

An MVC framework built in rust with design decisions inspired by LucidMVC

License: Other

Makefile 2.72% Rust 97.28%

rustymvc's Introduction

RustyMVC

RustyMVC is a portable MVC framework for Rust.

Goals

  1. Portable to different HTTP server interfaces (currently cgi-bin and rust-http)
  2. Embrace static typing, not work around it. As little reflection as possible

RustyMVC is based off of LucidMVC, an MVC framework with similar goals, but written in .NET. Although it is not intended to be source compatible in any way, most design decisions are influenced by my existing code there.

Building

Build the core framework by using the makefile.

make

You can run the test suite by using the test target

make test

You should also be capable of using rustpkg to build it, but I'm not currently worrying about it.

Example usage

Example usage varies because of portabiility to different HTTP servers, but here is an illustrative example:

struct TestController;

impl TestController{
    fn new() -> TestController{
    TestController
    }
    fn index(&mut self, context: &mut ControllerContext) {
        context.http.response.body.push_str("test index");
    }
    fn say(&mut self, context: &mut ControllerContext) {
        context.http.response.body.push_str(context.route_params[~"message"]);
    }
}

//In the server setup code:
let mut router=Router::new();
{
    let mut test = router.controller(|_| TestController::new()); 
    test.handles(~"/test").with(|c,ctx| c.index(ctx));
}
{
    let mut test = router.controller(|_| TestController::new()); 
    test.handles(~"/say/[message]").with(|c,ctx| c.say(ctx));
}

//Executed upon each request
let mut context=context();
router.execute(&mut context); 

It's still rough around the edges, but I'm still learning Rust, so it'll get better :)

Licensing

It is BSD licensed. I will not accept pull requests for LGPL or GPL licensed code. Other permissive licenses(MIT, etc) are fine though.

rustymvc's People

Contributors

earlz avatar eerden avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.