[Groonga-commit] droonga/droonga.org at eb11c3d [gh-pages] Add more descriptions about output messages

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Feb 19 19:08:07 JST 2014


YUKI Hiroshi	2014-02-19 19:08:07 +0900 (Wed, 19 Feb 2014)

  New Revision: eb11c3d9e43ee952b8b91f6fe2b8e764ffb23195
  https://github.com/droonga/droonga.org/commit/eb11c3d9e43ee952b8b91f6fe2b8e764ffb23195

  Message:
    Add more descriptions about output messages

  Modified files:
    reference/plugin/adapter/index.md

  Modified: reference/plugin/adapter/index.md (+47 -2)
===================================================================
--- reference/plugin/adapter/index.md    2014-02-19 18:41:43 +0900 (cf324d7)
+++ reference/plugin/adapter/index.md    2014-02-19 19:08:07 +0900 (21935a4)
@@ -227,11 +227,56 @@ end
 
 #### `#status_code`, `#status_code=(status_code)` {#classes-Droonga-OutputMessage-status_code}
 
-(under construction)
+This returns the `"statusCode"` of the outgoing message.
+
+You can override it by assigning a new status code. For example: 
+
+~~~ruby
+module FooPlugin
+  class Adapter < Droonga::Adapter
+    input_message.pattern = ["type", :equal, "search"]
+
+    def adapt_output(output_message)
+      unless output_message.status_code == StatusCode::InternalServerError
+        output_message.status_code = StatusCode::OK
+        output_message.body = {}
+        output_message.errors = nil
+        # Now any internal server error is ignored and clients
+        # receive regular responses.
+      end
+    end
+  end
+end
+~~~
 
 #### `#errors`, `#errors=(errors)` {#classes-Droonga-OutputMessage-errors}
 
-(under construction)
+This returns the `"errors"` of the outgoing message.
+
+You can override it by assigning new error information, partially or fully. For example:
+
+~~~ruby
+module FooPlugin
+  class Adapter < Droonga::Adapter
+    input_message.pattern = ["type", :equal, "search"]
+
+    def adapt_output(output_message)
+      output_message.errors.delete(secret_database)
+      # Delete error information from secret database
+
+      output_message.body["errors"] = {
+        "records" => output_message.errors.collect do |database, error|
+          {
+            "database" => database,
+            "error" => error
+          }
+        end,
+      }
+      # Convert error informations to a fake search result named "errors".
+    end
+  end
+end
+~~~
 
 #### `#body`, `#body=(body)` {#classes-Droonga-OutputMessage-body}
 
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index