@demetera, Nim is statically typed and has some type inference, so when you 
don't see a type listed, Nim's type inference is at work. The type of `headers` 
is a string, because Nim infers the type from the default value. 
`headers:string=""` could also be used equivalently.

As for how to use that proc, you'll have to look at how it's used in Jester. 
You can see [here](https://github.com/dom96/jester/blob/master/jester.nim#L91) 
on how to create the headers parameter.

So basic usage would be:
    
    
    import strutils
    import options
    import httpbeast, asyncdispatch
    import httpcore
    
    type
      RawHeaders = seq[tuple[key, val: string]]
    
    proc createHeaders(headers: RawHeaders): string =
      if headers.len > 0:
        var res: seq[string]
        for header in headers:
          let (key, value) = header
          res.add(key & ": " & value)
        
        return res.join("\c\L")
    
    proc onRequest(req: Request): Future[void] =
      let headers = @({"Myheader": "test"})
      
      if req.httpMethod == some(HttpGet):
        case req.path.get()
        of "/":
          req.send(HTTP200, "Hello!", headers=createHeaders(headers))
        else:
          req.send(Http404)
    
    run(onRequest)
    
    
    Run

Reply via email to