Skip to content

Commit ded45dc

Browse files
committed
net.http: support v -http -d http_folder=vlib/_docs (allow customizing the folder, port, and index file through CLI arguments to v -http)
1 parent 65767d2 commit ded45dc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

‎vlib/net/http/file/static_server.v‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import net.urllib
1111
@[params]
1212
pub struct StaticServeParams {
1313
pub mut:
14-
folder string = '.' // the folder, that will be used as a base for serving all static resources; If it was /tmp, then: http://localhost:4001/x.txt => /tmp/x.txt
15-
index_file string = 'index.html' // A request for http://localhost:4001/ will map to index.html, if that file is present.
16-
auto_index bool = true // when an index_file is *not* present, a request for http://localhost:4001/ will list automatically all files in the folder.
17-
filter_myexe bool = true // whether to filter the name of the static file executable from the automatic folder listings for / . Useful with `v -e 'import net.http.file; file.serve()'`
18-
on string = 'localhost:4001' // on which address:port to listen for http requests
14+
folder string = $d('http_folder', '.') // The folder, that will be used as a base for serving all static resources; If it was /tmp, then: http://localhost:4001/x.txt => /tmp/x.txt . Customize with `-d http_folder=vlib/_docs`.
15+
index_file string = $d('http_index_file', 'index.html') // A request for http://localhost:4001/ will map to `index.html`, if that file is present.
16+
auto_index bool = $d('http_auto_index', true) // when an index_file is *not* present, a request for http://localhost:4001/ will list automatically all files in the folder.
17+
on string = $d('http_on', 'localhost:4001') // on which address:port to listen for http requests.
18+
filter_myexe bool = true // whether to filter the name of the static file executable from the automatic folder listings for / . Useful with `v -e 'import net.http.file; file.serve()'`
1919
workers int = runtime.nr_jobs() // how many worker threads to use for serving the responses, by default it is limited to the number of available cores; can be controlled with setting VJOBS
2020
shutdown_after time.Duration = time.infinite // after this time has passed, the webserver will gracefully shutdown on its own
2121
}

0 commit comments

Comments
 (0)