Nancy framework TinyIoc magic

Been using the Nancy framework with mono, replacing some ASP.NET garbage left over from the dawn of time. I really like it and it works great, but the TinyIoc framework has been driving me totally nuts. What it does it does magically, but that whole “magic injection” thing is a nightmare the second you need to change one of the default behaviors and… nothing happens. Code compiles, runs without errors, but there’s no change.

Magic. Magic never changes.

I’m particularly impressed at how complex, powerful, and completely baffling and undocumented the request lifecycle is. There are a half-dozen functions that register different things, but all I want to do is use the same object to handle every request. The one thing I can’t figure out how to do is use the same object for every request. I’ve found several examples describing how this should work, but none of them worked for me. And, strangely, it seems to be creating the same object four times per request. This can’t be efficient.

I think the problem is that the people designing it are still thinking in terms of ASP.NET. That piece of junk will hold us back forever if we don’t shake free of its influence.

There’s another warning sign all through the forums. Any time someboyd has a question about how do solve a specific problem, he is immediately told that he needs to rethink his architecture. As a person porting an existing code base, who is trying to work around its current structure and limitations, this makes me question my decision to use Nancy. Responses like this are a sign that you’re dealing with people who do not actually have jobs.

And another thing…

Also, the “easy response syntax” that lets you return, say the number 404 to indicate that you want to send back a 404 result is nice, but this means there’s no “easy” way to return 404 with a custom error message. For example, if you want to return status 400 “Invalid request: the ‘count’ parameter is required’, you can either return the text with a 200, or 400 with no text, but not both. If you want to return both, you can easily return a Response object, which, er, is documented in the source code. There are a lot of very cool Response objects and it’s easy–if you wrote the framework or have the source code on disk.

I think I’m falling in love with Nancy, but I always have to guess what will make her happy. Somehow very familiar.

Leave a Reply

You must be logged in to post a comment.