Harfang 0.3 RC1

118 views
Skip to first unread message

Nicolas Juneau

unread,
Oct 28, 2012, 2:05:44 PM10/28/12
to Haxe language and help discussion group
Hello everybody,

Harfang 0.3 is ready for field testing. Thus, I pushed the Harfang 0.3 RC1 tag on Github last night (https://github.com/njuneau/Harfang/tree/release-0.3-rc1). For now you may download an archive from there and if there aren't outstanding bugs, 0.3 will be put on Haxelib. Final documentation should also be done by then.

I know it's been quite a while since 0.2, but I hope that this version's additions make it easier to use. So here's a rundown of the changes (since no new features will be added for the final release) :

First of all, if you upgrade from 0.1 or 0.2, some package names have changed. Every Harfang package name is now in the singular form (for example : harfang.exceptions is now harfang.exception). In previous releases, some package names were in the plural form and some others not. In order to improve consistency, everything was changed to singular form.

Regarding the Controller interface, it has been reported in the 0.2 release that handling output in a uniform way could be somewhat tedious without a return value. As I pointed out at the time, the return value is never exposed to the developer. Moreover, should the return value be used as output, the URL dispatcher would be responsible of handling the output format and also defining the output channel. As these two functions are not the concern of the dispatcher, I have put a new "handlePostRequest" method in the Controller interface that is called after each successful call to a controller's method. Thus, you may set an output result in your controllers and handle them in a uniform fashion using "handlePostRequest". Also note that "post" has nothing to do with the HTTP POST method, but rather has a "pre/post-request" meaning.

The MacroConfigurator should now be working again for Haxe 2.10. There was a change in Haxe's macro behaviour between Haxe 2.09 and Haxe 2.10 that prevented the MacroConfigurator from properly working. It should now be fine!

The ServerConfiguration interface now has an "init" method in which you should initialize the configuration. If you used the constructor before, you should move everything to "init" and leave the constructor only with the "super" call. You may refer to the 0.3 quick start guide section 5 (http://haxe.org/com/libs/harfang/tutorials/quickstart/0.3#5-creating-the-application-s-configuration) for the configuration mechanic if you are unsure on how to proceed. The "init" method has been introduced because the constructor is not part of the ServerConfiguration interface. In the future, should parameters be introduced to the ServerConfiguration's initialization sequence, adding parameters to the "init" method will be immediately visible to the developer (whereas constructor parameters cannot be defined in the interface).

Last but not least, Harfang 0.3 introduces server event listeners. This new feature lets a developer create listeners that handle events like "onHTTPerror", "onDipsatch" and, for now, a couple of others. In previous Harfang releases, error handling could only be done from the configuration class. Although that may have been practical if error handling was "site-wide", it was not practical if error handling needed to be done elsewhere. Thus, the developer may now create classes that implement the ServerEventListener interface and add the listeners to the configuration should he want to have components react to events. An example may be a request logger that logs every requests and errors to a text file. Another one may be a module instance that is event-aware and handles exceptions by itself. But don't worry - if you handled all your errors in UserConfiguration and that it extended AbstractServerConfiguration, it should continue to work as AbstractServerConfiguration now implements ServerEventListener and adds itself to the list of active listeners at initialization. For more details, consult the server event listener howto (http://haxe.org/com/libs/harfang/tutorials/howto_server_event_listeners/0.3). The guide is still a work in progress, but should help you get started.

That's about it! A summary of the changes may be obtained there, as always : https://github.com/njuneau/Harfang/blob/release-0.3-rc1/CHANGES .

If you wonder what's left for future releases, Harfang 0.4 will probably just be a transitional release for Haxe 3. For Harfang 0.5, I thought of looking into configuration initialization and maybe try to add a way of specifying the HTTP method in URL mappings to ease the development of REST services.

Enjoy and as always, comments are welcome! If you find any issues, don't forget to file them on Github!
-- 
Nicolas Juneau
Reply all
Reply to author
Forward
0 new messages