Skip to content
This repository has been archived by the owner on Jul 6, 2024. It is now read-only.

Proposal: Alternative handler signature #9

Closed
akyoto opened this issue May 28, 2019 · 4 comments
Closed

Proposal: Alternative handler signature #9

akyoto opened this issue May 28, 2019 · 4 comments
Labels

Comments

@akyoto
Copy link
Contributor

akyoto commented May 28, 2019

I'd like to know what people's thoughts are on changing the aero.Handle signature from returning a string to returning an error object.

Since most people are calling ctx.HTML before returning the http body we can adjust ctx.HTML to return an error object alongside the other content types and people would have no troubles adopting the new signature. A search and replace would do the job.

The advantage is that the error return type feels more like idiomatic Go code whereas the string type forces us to do things like return "" on not-in-memory responses like ctx.File or ctx.EventStream. return nil feels a little cleaner.

Thoughts?

@akyoto akyoto pinned this issue May 28, 2019
@akyoto akyoto unpinned this issue May 28, 2019
@akyoto
Copy link
Contributor Author

akyoto commented May 28, 2019

I have performed the changes in a separate branch, see the commit a0c5980.

We end up with quite a few code deletions and overall cleaner code. I believe this is a step in the right direction.

@soulcramer
Copy link

soulcramer commented May 28, 2019

I think this change is great, it does look more idiomatic but as you said this change will break on the client side. Maybe it's the occasion to add two or three other breaking changes so the user have to handle these only in the next version?

I like where you're going with aerogo 😄

@akyoto
Copy link
Contributor Author

akyoto commented May 29, 2019

Normally, breaking changes can easily be handled by a major version upgrade in the semver number.

In the case of Go, however, this would cause everyone to start using "/v2" suffixed import paths in every single import which I vehemently disagree with. Import paths declare which library I'm using, not at which (major) version I am using it. Import paths should not be doing something they are not concerned with. We have a go.mod file to do versioning for us.

Using the version that is explicitly stated in the go.mod should be the default behaviour, that means no suffix should ever be required for importing the exact version that is stated in the go.mod file.

For this reason, I will have to resort to a minor version upgrade for breaking changes, even if it does not adhere to semver rules.

This is sad but I don't see another solution within the current state of Go modules.

@akyoto
Copy link
Contributor Author

akyoto commented May 30, 2019

Further discussion around this topic can be seen here:
https://groups.google.com/forum/#!msg/golang-dev/MNQwgYHMEcY/ScU6RIgICwAJ

@aerogo aerogo locked and limited conversation to collaborators Jun 1, 2019
@akyoto akyoto closed this as completed Jun 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

2 participants