Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

一些建议 #6

Open
iredmail opened this issue Mar 30, 2020 · 0 comments
Open

一些建议 #6

iredmail opened this issue Mar 30, 2020 · 0 comments

Comments

@iredmail
Copy link

iredmail commented Mar 30, 2020

  • 老调重弹:去掉 register()。还没人用 V 和 valval,真没必要在这个阶段考虑向后兼容的问题。
  • route 的部分,是否将 http method 从 url 里剥离出来?现在将 http method 直接写进了 url 里,导致在处理的时候还要从字符串里剥离出 http method,多了一个字符串处理的工作。
app.route('POST:/book', function3)  // http://127.0.0.1/book by POST
app.route('DELETE:/book', function4)    // http://127.0.0.1/book by DELETE

也许增加个函数用于接收 http method?例如:

app.routeX('/book', function3, ['POST'])
app.routeX('/book', function4, ['DELETE'])
app.route_get('/book', function3)
app.route_delete('/book', function4)
  • App 能否扩展一下,直接传入一个 map,里面可以有参数:
    • static files 目录
    • debug: bool
    • listen address
    • listen port

例如:

struct Cfg {
        debug bool = false
        static_dirs map[string]string
        listen_address string = '127.0.0.1'
        listen_port int = 8012
}

fn main() {
        cfg := Cfg{debug: false, static_dirs: {'/dir1': '/opt/www/dir1'}, listen_address: '0.0.0.0', listen_port: 8012}
	mut app := valval.new_app(cfg)
	app.route('/', hello)
	valval.runserver()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant