ドキュメント

View Categories

RestAPIサーバー

< 1 min read

DrogonのRestAPIでデータベースの操作を行います。

https://share.google/aimode/OwXQSj0LKRpaIu282

share/sql/slite3/<api>のsqlを読み込み操作に合わせて使用します。

GET操作ではSELECT文でデータを取得した後、set_record(Format& format, Result& row)でFormatクラスに変換し、Jsonレスポンスをクライアントへ返します。

POST、PUT、DELETE操作ではjsonメッセージをFormatクラスに変換します。このときバリデーションチェックを行い、エラーの場合は401BadRequestレスポンスを返します。

エラーがなければSQLにFormatクラスのデータを使用してデータベースを操作します。

データベース操作でエラーが発生した場合、500InternalServerErrorレスポンスを返します。

エラーがなければ200okレスポンスを返します。

GET操作はJsonレスポンス以外にもHttpレスポンスがあります。ブラウザでRestAPIの操作が可能なViewを返します。

クライアント画面がなくてもRestAPIのテストが可能です。

以下が利用可能なAPIのURLです。

http://localhost/initializers

http://localhost/account_items?year={%Y}

http://localhost/account_items/json?year={%Y}

http://localhost/journal_descriptions?year={%Y}

http://localhost/journal_descriptions/json?year={%Y}

http://localhost/journals?year={%Y}

http://localhost/journals/json?year={%Y}

http://localhost/journal_closed?year={%Y}

http://localhost/journal_closed/json?year={%Y}

http://localhost/general_ledgers/journal_closed_id={%d}

http://localhost/general_ledgers/json/journal_closed_id={%d}

http://localhost/financial_statements/journal_closed_id={%d}

http://localhost/financial_statements/json/journal_closed_id={%d}

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です