Tree-like Web Server

Triditional WebServer Architecture design include:

  • MVC

  • File-Based

  • express-like

Example

return STree(
    db: [
        MySqlDatabase(
            host: 'localhost',
            username: 'root',
            password: secret['password'],
        ),
    ],
    middleware: [
        MyAuthenticationMiddleWare(),
    ],
    routes: {
        group('/'): (ctx) => view('index'), 
        get('/home'): redirect('/home'),
        group('/api': guard(
            accept: handleApi,
            decline: redirect('/home'),
            check: authChecker,
        ),
        group('/user') : (ctx) => {
                get('/name'): (ctx) => ctx.user.name,
                post('/name'): (ctx) => ctx.user.name = ctx.params['name'],
        },
    },
    exceptions: (e){
        try{throw e;}
        on Exception {

        }
        on OtherException {

        }
        on AuthException {

        }
    },
    },
);

Last updated