Vex
Web framework written on V inspired by Express and Sinatra.
Vex is still in its early stages and some of the parts were not implemented yet.
module main
import vex.server as vex
import json
import os
struct Person {
name string
doing string
}
fn show_root(req vex.Request, res mut vex.Response) {
res.send_file('index.html', 200)
}
fn print_json(req vex.Request, res mut vex.Response) {
res.send_json(json.encode(Person{ name: req.params['name'], doing: req.params['doing'] }), 200)
}
fn log_server(req vex.Request, res vex.Response) {
println('${req.path}')
}
fn main() {
mut s := vex.new()
s.serve_static('public')
s.get('/', show_root)
s.get('/hey/:name/:doing', print_json)
s.connect(log_server, ['*', '!/hey']) // middleware
s.serve(6789)
}
vweb
vex and Vex is committed to bring some of its features and optimizations to the vweb framework once it is stable.
Dependencies
Vex uses v-mime to identify MIME types when serving files.
Roadmap
- Support for
GET
,POST
,PUT
,PATCH
,DELETE
, andOPTION
HTTP methods. - HTTP Router (wildcards not yet supported)
- Static file server
- Params and query parsing
- Body parsing (supports raw text for now)
- Middleware support
- Cookie parsing (basic support)
- Form data parsing
-
application/x-www-form-urlencoded
support -
multipart/form-data
support
-
Contributing
- Fork it (https://github.com/nedpals/vex/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Examples
Examples can be found at the /examples
directory.
License
Contributors
- Ned Palacios - creator and maintainer