README.md in macaw_framework-0.2.0 vs README.md in macaw_framework-1.0.0

- old
+ new

@@ -1,9 +1,7 @@ # MacawFramework -<img src="macaw_logo.png" alt= “” style="width: 30%;height: 30%;margin-left: 35%"> - This is a framework for developing web applications. Please have in mind that this is still a work in progress and it is strongly advised to not use it for production purposes for now. Actually it supports only HTTP. and HTTPS/SSL support will be implemented soon. Anyone who wishes to contribute is welcome. ## Installation @@ -29,18 +27,44 @@ "port": 8080, "bind": "localhost", "threads": 10, "cache": { "cache_invalidation": 3600 + }, + "prometheus": { + "endpoint": "/metrics" + }, + "rate_limiting": { + "window": 10, + "max_requests": 3, + "ignore_headers": [ + "header-to-be-ignored-from-caching-strategy", + "another-header-to-be-ignored-from-caching-strategy" + ] + }, + "ssl": { + "ssl": { + "cert_file_name": "path/to/cert/file/file.crt", + "key_file_name": "path/to/cert/key/file.key" + } } } } ``` Cache invalidation time should be specified in seconds. In order to enable caching, The application.json file -should exist in the app main directory and it need the `cache_invalidation` config set. +should exist in the app main directory and it need the `cache_invalidation` config set. It is possible to +provide a list of strings in the property `ignore_headers`. All the client headers with the same name of any +of the strings provided will be ignored from caching strategy. This is useful to exclude headers like +correlation IDs from the caching strategy. +Rate Limit window should also be specified in seconds. Rate limit will be activated only if the `rate_limiting` config +exists inside `application.json`. + +If the SSL configuration is provided in the `application.json` file with valid certificate and key files, the TCP server +will be wrapped with HTTPS security using the provided certificate. + Example of usage: ```ruby require 'macaw_framework' require 'json' @@ -49,11 +73,11 @@ m.get('/hello_world', cache: true) do |context| context[:body] # Returns the request body as string context[:params] # Returns query parameters and path variables as a hash context[:headers] # Returns headers as a hash - return JSON.pretty_generate({ hello_message: 'Hello World!' }), 200 + return JSON.pretty_generate({ hello_message: 'Hello World!' }), 200, {"Content-Type" => "application/json"} end m.post('/hello_world/:path_variable') do |context| context[:body] # Returns the request body as string context[:params] # Returns query parameters and path variables as a hash @@ -68,12 +92,12 @@ The example above starts a server and creates a GET endpoint at localhost/hello_world. If prometheus is enabled, a get endpoint will be defined at path `/metrics` to collect prometheus metrics. This path is configurable via the `application.json` file. -The verb methods must always return a string or nil (used as the response) and a number corresponding to the HTTP status -code to be returned to the client. If an endpoint doesn't return a value or returns nil for both the string and the -code, a default 200 OK status will be sent as the response. +The verb methods must always return a string or nil (used as the response), a number corresponding to the HTTP status +code to be returned to the client and the response headers as a Hash or nil. If an endpoint doesn't return a value or +returns nil for body, status code and headers, a default 200 OK status will be sent as the response. ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/ariasdiniz/macaw_framework. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/ariasdiniz/macaw_framework/blob/main/CODE_OF_CONDUCT.md).