First attempt at writing PUT route
ci/woodpecker/push/woodpecker Pipeline failed
Details
ci/woodpecker/push/woodpecker Pipeline failed
Details
parent
625018518d
commit
12aff4ff9f
|
@ -1,3 +1,6 @@
|
|||
*.c
|
||||
data/
|
||||
vieter/vieter
|
||||
|
||||
# Ignore testing files
|
||||
*.pkg*
|
||||
|
|
2
Makefile
2
Makefile
|
@ -1,6 +1,6 @@
|
|||
.PHONY: run
|
||||
run:
|
||||
API_KEY=test REPO_DIR=data v run vieter
|
||||
API_KEY=test REPO_DIR=data v watch run vieter
|
||||
|
||||
.PHONY: fmt
|
||||
fmt:
|
||||
|
|
|
@ -17,17 +17,27 @@ fn exit_with_message(code int, msg string) {
|
|||
exit(code)
|
||||
}
|
||||
|
||||
[put; '/pkgs/:filename']
|
||||
fn (mut app App) put_package(filename string) vweb.Result {
|
||||
os.write_file('$app.repo_dir/$filename', app.req.data) or {
|
||||
return app.text(err.msg)
|
||||
}
|
||||
|
||||
return app.text('yeet')
|
||||
}
|
||||
|
||||
fn main() {
|
||||
key := os.getenv_opt('API_KEY') or { exit_with_message(1, 'No API key was provided.') }
|
||||
repo_dir := os.getenv_opt('REPO_DIR') or {
|
||||
exit_with_message(1, 'No repo directory was configured.')
|
||||
}
|
||||
println(repo_dir)
|
||||
|
||||
// We create the upload directory during startup
|
||||
if !os.is_dir(repo_dir) {
|
||||
os.mkdir_all(repo_dir) or { exit_with_message(2, 'Failed to create repo directory.') }
|
||||
os.mkdir_all(repo_dir) or { exit_with_message(2, "Failed to create repo directory '$repo_dir'.") }
|
||||
|
||||
println('Repo directory created.')
|
||||
println("Repo directory '$repo_dir' created.")
|
||||
}
|
||||
|
||||
vweb.run(&App{
|
||||
|
|
Loading…
Reference in New Issue