segmentio / nsq-go

Go package providing tools for building NSQ clients, servers and middleware.
MIT License
100 stars 20 forks source link

Support the more flattened HTTP response, supporting nsq v1+ #35

Open abourget opened 5 years ago

abourget commented 5 years ago

I noticed in handler.go:

    v1 := req.Header.Get("Accept") == "application/vnd.nsq; version=1.0"

    if !v1 {
        value = struct {
            StatusCode int         `json:"status_code"`
            StatusText string      `json:"status_txt"`
            Data       interface{} `json:"data"`
        }{
            StatusCode: status,
            StatusText: text,
            Data:       value,
        }
    }

We could also do something similar here to support both versions.. a bit more refactoring would need to happen through, to bubble up the headers alongside the ret, or the ret could be a channel of more structured objects, like the LookupResult itself..