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 server.Request, res mut server.Response) {
res.send_file('index.html', 200)
}
fn print_json(req server.Request, res mut server.Response) {
res.send_json(json.encode(Person{ name: req.params['name'], doing: req.params['doing'] }), 200)
}
fn log_server(req server.Request, res server.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)
}
Vex is committed to bring some of its features and optimizations to the vweb framework once it is stable.
Vex uses v-mime to identify MIME types when serving files.
- 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
-
- 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 can be found at the /examples
directory.
- Ned Palacios - creator and maintainer