0

I'm new to node.js, have been using Ruby and RoR.

I'd like to show a view for user view with a pretty routing.

In Rails, I can handle with code like this:

get '@:username' => 'users#show'

So I tried in Total.js as same, but error appeaerd with 404: Not found:

exports.install = function() {
  F.route('/@{username}', view_user);
}

How can I get my user view with localhost:8000/@my_name in total.js?

Nyeong
  • 3
  • 1

1 Answers1

0

You must remove @ from the route:

exports.install = function() {
    F.route('/{username}/', view_user);
};

function view_user(username) {
    if (!username.startsWith('@')) {
        this.throw404();
    else
        this.plain(username);
});

Thanks.

Peter Sirka
  • 748
  • 5
  • 10