feat: implement HeroFS REST API server
- Add server entrypoint and main function - Implement API endpoints for filesystems - Implement API endpoints for directories - Implement API endpoints for files - Implement API endpoints for blobs - Implement API endpoints for symlinks - Implement API endpoints for blob membership - Implement filesystem tools endpoints (find, copy, move, remove, list, import, export) - Add health and API info endpoints - Implement CORS preflight handler - Add context helper methods for responses - Implement request logging middleware - Implement response logging middleware - Implement error handling middleware - Implement JSON content type middleware - Implement request validation middleware - Add documentation for API endpoints and usage
This commit is contained in:
2
examples/hero/herofs/.gitignore
vendored
2
examples/hero/herofs/.gitignore
vendored
@@ -1 +1,3 @@
|
||||
herofs_basic
|
||||
herofs_server
|
||||
fs_server
|
||||
|
||||
34
examples/hero/herofs/fs_server.vsh
Executable file
34
examples/hero/herofs/fs_server.vsh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals -no-skip-unused run
|
||||
|
||||
import freeflowuniverse.herolib.hero.herofs_server
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
fn main() {
|
||||
console.print_header('HeroFS REST API Server Example')
|
||||
|
||||
// Create server with CORS enabled for development
|
||||
mut server := herofs_server.new(
|
||||
port: 8080
|
||||
host: 'localhost'
|
||||
cors_enabled: true
|
||||
allowed_origins: ['*'] // Allow all origins for development
|
||||
)!
|
||||
|
||||
console.print_item('Server configured successfully')
|
||||
console.print_item('Starting server...')
|
||||
console.print_item('')
|
||||
console.print_item('Available endpoints:')
|
||||
console.print_item(' Health check: GET http://localhost:8080/health')
|
||||
console.print_item(' API info: GET http://localhost:8080/api')
|
||||
console.print_item(' Filesystems: http://localhost:8080/api/fs')
|
||||
console.print_item(' Directories: http://localhost:8080/api/dirs')
|
||||
console.print_item(' Files: http://localhost:8080/api/files')
|
||||
console.print_item(' Blobs: http://localhost:8080/api/blobs')
|
||||
console.print_item(' Symlinks: http://localhost:8080/api/symlinks')
|
||||
console.print_item(' Tools: http://localhost:8080/api/tools')
|
||||
console.print_item('')
|
||||
console.print_item('Press Ctrl+C to stop the server')
|
||||
|
||||
// Start the server (this blocks)
|
||||
server.start()!
|
||||
}
|
||||
Reference in New Issue
Block a user