hashicorp/consul — pull request #78 by tarrant (2014-04-25 02:54:29+00:00)
Title: Case insensitive durations

As it currently stands the example input for '/v1/agent/service/register' fails with following errors:

```
Request decode failed: 2 error(s) decoding:

* 'Check.Interval' expected type 'time.Duration', got unconvertible type 'string'
* 'Check.TTL' expected type 'time.Duration', got unconvertible type 'string'
```

I've adjusted the mangling of JSON to do case insensitive searches for the keys that need to be adjusted.

On a side note rather than mucking around with interface{} would it be worth defining a wrapper around time.Duration with a custom Unmarshaler?

Something along the lines of:

```
type JSONDuration struct {
time.Duration
}

func (j *JSONDuration) UnmarshalJSON([]byte) error {
dur, err := time.ParseDuration(intervalS)
if err != nil {
return err
}
j.Duration = dur
return nil
}
```

Granted it does require a bit more work when you want to access the Duration.