Well, I tried add condition statement in the multi-method and found it worked 
very well, and here is my tiny view dispatch framework!:
    
    
    type
      Document = ref object of RootObj
        text: string
      Request = ref object of RootObj
        reqMethod: string
    
    method view(doc: Document, req: Request): string {.base.} =
      if req.reqMethod=="GET":
        return doc.text
    
    let doc = Document(text: "Hello World!")
    echo view(doc, Request(reqMethod: "GET"))
    
    
    Run

Reply via email to