Only initialize simple server's methods after it's being required.
@@ -26,15 +26,15 @@ func initializeSimpleServerClass(vm *VM) {
initializeHTTPClass(vm)
net := vm.loadConstant("Net", true)
simpleServer := initializeClass("SimpleServer", false)
- simpleServer.setBuiltInMethods(builtinSimpleServerInstanceMethods, false)
+ simpleServer.setBuiltInMethods(builtinSimpleServerInstanceMethods(), false)
net.constants[simpleServer.Name] = &Pointer{simpleServer}
vm.execGobyLib("net/simple_server.gb")
}
-var builtinSimpleServerInstanceMethods = []*BuiltInMethodObject{
- {
- Name: "start",
+func builtinSimpleServerInstanceMethods() []*BuiltInMethodObject {
+ return []*BuiltInMethodObject{
+ {Name: "start",
Fn: func(receiver Object) builtinMethodBody {
return func(t *thread, args []Object, blockFrame *callFrame) Object {
var port string
@@ -90,6 +90,7 @@ var builtinSimpleServerInstanceMethods = []*BuiltInMethodObject{
},
},
}
+}
func initRequest(req *http.Request) *RObject {
r := request{}
