Files
herolib/lib/hero/heromodels/factory_server.v
2025-10-12 12:30:19 +03:00

37 lines
916 B
V

module heromodels
import incubaid.herolib.hero.heroserver
import incubaid.herolib.crypt.herocrypt
// Start heromodels server using heroserver
@[params]
pub struct ServerArgs {
pub mut:
port int = 8080
host string = 'localhost'
auth_enabled bool = true
cors_enabled bool = true
reset bool
allowed_origins []string = ['*'] // Default allows all origins
name string
crypto_client ?&herocrypt.HeroCrypt
}
pub fn server_start(args ServerArgs) ! {
// Create a new heroserver instance
mut server := heroserver.new(
port: args.port
host: args.host
auth_enabled: args.auth_enabled
cors_enabled: args.cors_enabled
allowed_origins: args.allowed_origins
crypto_client: args.crypto_client
)!
mut f := get(args.name)!
server.register_handler('heromodels', f.rpc_handler)!
// Start the server
server.start()!
}