Agile software development using Kanban & Scrum. We code Flex & Ruby on Rails in Auckland, New Zealand.

  • Couch and Flex. First Steps.

    I had this idea that I wanted to replace TraceTarget (the default Flex logging target) with CouchTarget. That way, instead of producing .csv text I could sort and filter in excel. I could get realtime (or close to) in couch and write views/shows that narrowed down my debug session.

    So off I went, and it did not go well.

    Step 1: Installing CouchDB

    I have an Ubuntu instance so I just installed couch with Aptitude. I did some tutorials and was loving Couch in minutes.

    Step 2: Talk to couch from flex.

    Ouch. So couch wants ‘PUT’ methods, and fair enough too. But I know I can’t do that from URLLoader. I played with some other solutions, like the as3http library, but I really didn’t want something so OTT for a simple logger. So I searched for a magic bullet I knew had to be there.

    PUT when you can’t

    In RubyOnRails rest calls, you simply provide _method=put as a parameter to a POST and you get PUT. This is because some clients (Flash player included) cannot PUT, they can only GET and POST.

    So I went looking throught the CouchDB docs to see if it supported an alternative to ‘PUT’. Nothing came up. I was still sure it MUST support it somehow though. So I went looking around for other alternatives. I finally stumble upon the X-HTTP-Method-Override header.

    Eureka! right? wrong..

    X-HTTP-Method-Override support

    I tried it, it did not work. I thought, well, couch does not support this…

    Searching for X-HTTP-Method-Override and CouchDB finally turned up a changelog, where it was added in some version, which was clearly newer than the 0.10 version Ubuntu installs.

    Moral

    Install CouchDB >1.0.

    CouchOne do great installers

    Example

    Heres the crufty first draft of my Logger

    It has dependencies you wont have so don’t expect it to run, or play nice. But it does show how I got posts going. RestfulX provided an easy method for adding headers and also kept me believing it was possible with URLLoader, because they do it too.

    1. vworkdev posted this