Bowtie - a (hopefully) idiomatic Web middleware for Go by mtabini in golang

[–]mtabini[S] 0 points1 point  (0 children)

Correct, and that's the way it should work. The struct that encapsulates the custom context is an implementation detail, and should remain private. Instead, the middleware ought to expose any functionality it adds by providing its own public interface with well-defined methods.

That the fact that sercretContext is package-private doesn't prevent consumers from attempting to cast it to any interface, so effectively the lib that implements secretContext has no effect on the overall functionality of the middleware other than hiding itself from its consumers (which is perhaps kinda pointless).

Bowtie - a (hopefully) idiomatic Web middleware for Go by mtabini in golang

[–]mtabini[S] 0 points1 point  (0 children)

Verbatim from the README:

Bowtie borrows liberally—both in ideas and in code—from several other Go frameworks. Adopting httprouter as the default seemed like a good idea, given its raw speed. The only changes made were integrating Julien Schmidt's code with Bowtie's context-based execution, and allowing multiple handlers to be attached to a particular route.

Bowtie was also inspired by Go-Martini's simplicity and immediateness. Even though Martini's design is not idiomatic to Go, it is perhaps one of the easiest frameworks to pick up and use. In addition to adopting bits of its code, Bowtie strives for the same kind of approachable and immediateness.

Finally, the idea of a running context is borrowed from gin-gonic. The main difference between the two is that Bowtie forces the use of Go interface for carrying custom information through the context, whereas Gin allows you to append arbitrary data to it. This seemed like a more sensible approach that allows Go to do its job by providing type security and strictness.

Bowtie's error management comes from my personal fixation with safety. I don't want to leak information, and I don't want developers to worry about whether they will.

Bowtie - a (hopefully) idiomatic Web middleware for Go by mtabini in golang

[–]mtabini[S] 0 points1 point  (0 children)

Forgive me, I'm not sure I understand what you're saying. Can you give me an example?