<commit_before>rest-contract
=============

An API for describing a REST contract via examples. This provides a client and a server that will run according to the rules in this contract. This was designed with testing RESTful clients and RESTful services independently.


*Create a Contract*

        Contract contract = new Contract();
        contract.rule(Request.get("api/v1/"), Response.code(200).body("ThoughtStreams API").header("Content-Type", "text/plain"));
        contract.rule(Request.get("foo"), Response.code(200).body("bar").header("Content-Type", "text/plain"));
        contract.rule(Request.get("fooh"), Response.code(200).body("bar").header("Content-Type", "text/html"));
        contract.rule(Request.get("asdfasdfa"), Response.code(404).body("Go away").header("Content-Type", "text/html")).then(Request.get("asdfasdfa"), Response.code(404).body("Go away or I will taunt you a second time").header("Content-Type", "text/html"));


*Create a Server that will follow the rules*

        new ContractServer().start("http://localhost:5555/", contract);

_you can now test your RESTful client against this_
        
*Create a Client and run the rules*        ContractClient client = new ContractClient(contract);

        client.run("http://localhost:5555/");
        Thread.sleep(1000000);

_you can now test your RESTful service using this_<commit_msg>Tidy up markdown (I hope)<commit_after>rest-contract
=============

An API for describing a REST contract via examples. This provides a client and a server that will run according to the rules in this contract. This was designed with testing RESTful clients and RESTful services independently.


**Create a Contract**

        Contract contract = new Contract();
        contract.rule(Request.get("api/v1/"), 
                      Response.code(200).body("ThoughtStreams API")
                              .header("Content-Type", "text/plain"));
        contract.rule(Request.get("foo"), 
                      Response.code(200)
                              .body("bar")
                              .header("Content-Type", "text/plain"));
        contract.rule(Request.get("fooh"), 
                      Response.code(200)
                              .body("bar")
                              .header("Content-Type", "text/html"));
        contract.rule(Request.get("asdfasdfa"), 
                      Response.code(404).body("Go away")
                              .header("Content-Type", "text/html"))
                .then(Request.get("asdfasdfa"), 
                      Response.code(404)
                              .body("Go away or I will taunt you a second time")
                              .header("Content-Type", "text/html"));




**Create a Server that will follow the rules**

        new ContractServer().start("http://localhost:5555/", contract);

_you can now test your RESTful client against this_
        



**Create a Client and run the rules**

        ContractClient client = new ContractClient(contract);
        client.run("http://localhost:5555/");
        Thread.sleep(1000000);
        
_you can now test your RESTful service using this_
{'fraction_non_alphanumeric': 0.1319796954314721, 'fraction_numerical': 0.01967005076142132, 'mean_word_length': 2.476295479603087, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6140350', 'n_tokens_mistral': 863, 'n_tokens_neox': 782, 'n_words': 236}