...
This commit is contained in:
@@ -4,23 +4,18 @@ import freeflowuniverse.herolib.hero.heroserver
|
||||
import freeflowuniverse.herolib.schemas.openrpc
|
||||
import os
|
||||
|
||||
mut server := heroserver.new_server(heroserver.ServerConfig{
|
||||
port: 8080
|
||||
auth_config: heroserver.AuthConfig{}
|
||||
})!
|
||||
// 1. Create a new server instance
|
||||
mut server := heroserver.new(port: 8080)!
|
||||
|
||||
// Register the comments API with documentation
|
||||
// 2. Create and register your OpenRPC handlers
|
||||
// These handlers must conform to the `openrpc.OpenRPCHandler` interface.
|
||||
script_dir := os.dir(@FILE)
|
||||
openrpc_path := os.join_path(script_dir, 'openrpc.json')
|
||||
spec := openrpc.new(path: openrpc_path)!
|
||||
handler := openrpc.new_handler(openrpc_path)!
|
||||
server.register_api('comments', spec, handler)
|
||||
|
||||
// Setup documentation site
|
||||
server.setup_docs_site() or { println('Warning: Failed to setup documentation site: ${err}') }
|
||||
server.register_handler('comments', handler)!
|
||||
|
||||
println('Server starting on http://localhost:8080')
|
||||
println('Documentation available at: http://localhost:8080/docs')
|
||||
println('Documentation available at: http://localhost:8080/doc/comments/')
|
||||
println('Comments API available at: http://localhost:8080/api/comments')
|
||||
|
||||
server.start()!
|
||||
|
||||
Reference in New Issue
Block a user