coder / hat

HTTP API testing for Go
MIT License
37 stars 3 forks source link

should we provide a method enumeration in this lib? #10

Closed nhooyr closed 6 years ago

nhooyr commented 6 years ago

https://github.com/codercom/hat/blob/51b4351671193d4c595303ca568ea9dd5e439592/method.go#L6

Feels like something that is more general than testing. Maybe into chttp? Does gin provide anything?

nhooyr commented 6 years ago

Maybe we should write our own router 😂

ammario commented 6 years ago

chttp isn't a bad place

nhooyr commented 6 years ago

Another possibility is to add methods for each request. E.g. instead of Request(), we use Get() and GetPath.

nhooyr commented 6 years ago

Maybe we should only have GetPath, one could just provide an empty path. Though, that seems janky so nvm.

ammario commented 6 years ago

Using Path methods are really an antipattern. Your RequestOptions should set the dynamic components of the path.

ammario commented 6 years ago

but I like the method enumeration instead of Request

nhooyr commented 6 years ago

Then why do we provide RequestURL?

ammario commented 6 years ago

My bad, it's usually an antipattern, but there are some cases where I think it's fine. E.g it would be overkill for the example/helloworld test to use options

nhooyr commented 6 years ago

I think we should go with consistency here. If the functional options can do it, we shouldn't provide another method, even though it may be overkill in certain cases.