{"result":{"depiction_url":null,"edges":{"hasreference":{"objects":[{"created":"2026-10-07T11:13:45Z","object_id":{"id":1537,"is_a":["text","documentation","reference","controller"],"name":"doc_controller_controller_template","title":"controller_template","uri":"https:\/\/zotonic.com\/id\/1537"},"seq":1},{"created":"2026-10-07T11:13:45Z","object_id":{"id":1875,"is_a":["text","documentation","reference","controller"],"name":"doc_controller_controller_api","title":"controller_api","uri":"https:\/\/zotonic.com\/id\/1875"},"seq":2}],"predicate":{"id":2774,"is_a":["meta","predicate"],"name":"hasreference","title":{"_type":"trans","tr":{"en":"Documentation reference"}},"uri":"https:\/\/zotonic.com\/id\/hasreference"}},"references":{"objects":[{"created":"2020-05-30T05:47:51Z","object_id":{"id":1279,"is_a":["text","documentation"],"name":"doc_glossary","title":"Glossary","uri":"https:\/\/zotonic.com\/id\/1279"},"seq":1000000},{"created":"2020-05-30T05:47:51Z","object_id":{"id":1296,"is_a":["text","documentation","reference","module"],"name":"doc_module_mod_base","title":"mod_base","uri":"https:\/\/zotonic.com\/id\/1296"},"seq":1000000},{"created":"2020-05-30T05:47:51Z","object_id":{"id":321,"is_a":["meta","category"],"name":"controller","title":"Controllers","uri":"https:\/\/test.zotonic.com\/id\/321"},"seq":1000000}],"predicate":{"id":332,"is_a":["meta","predicate"],"name":"references","title":{"_type":"trans","tr":{"en":"References"}},"uri":"https:\/\/zotonic.com\/id\/references"}},"refers":{"objects":[{"created":"2026-10-07T11:13:01Z","object_id":{"id":1537,"is_a":["text","documentation","reference","controller"],"name":"doc_controller_controller_template","title":"controller_template","uri":"https:\/\/zotonic.com\/id\/1537"},"seq":1000000},{"created":"2026-10-07T11:13:01Z","object_id":{"id":1875,"is_a":["text","documentation","reference","controller"],"name":"doc_controller_controller_api","title":"controller_api","uri":"https:\/\/zotonic.com\/id\/1875"},"seq":1000000}],"predicate":{"id":2409,"is_a":["meta","predicate"],"name":"refers","title":{"_type":"trans","tr":{"en":"Refers"}},"uri":"https:\/\/zotonic.com\/id\/refers"}},"relation":{"objects":[{"created":"2026-10-07T11:13:45Z","object_id":{"id":2940,"is_a":["text","documentation","developerguide"],"name":"developer_request_path","title":{"_type":"trans","tr":{"en":"Follow a request to its template"}},"uri":"https:\/\/zotonic.com\/id\/2940"},"seq":1},{"created":"2026-10-07T11:13:45Z","object_id":{"id":2966,"is_a":["text","documentation","developerguide"],"name":"developer_http_api","title":{"_type":"trans","tr":{"en":"Expose an operation through an API"}},"uri":"https:\/\/zotonic.com\/id\/2966"},"seq":2},{"created":"2026-10-07T11:13:45Z","object_id":{"id":1536,"is_a":["text","documentation","developerguide"],"name":"doc_developerguide_access_control","title":{"_type":"trans","tr":{"en":"Keep permission checks at the boundary"}},"uri":"https:\/\/zotonic.com\/id\/1536"},"seq":3}],"predicate":{"id":303,"is_a":["meta","predicate"],"name":"relation","title":{"_type":"trans","tr":{"nl":"Relatie","en":"Relation"}},"uri":"http:\/\/purl.org\/dc\/terms\/relation"}},"subject":{"objects":[{"created":"2026-10-07T11:13:45Z","object_id":{"id":2554,"is_a":["categorization","keyword","keyword_information_type"],"name":"zotonic_topic_how_to_guide","title":"How-to guide","uri":"https:\/\/zotonic.com\/id\/2554"},"seq":1},{"created":"2026-10-07T11:13:45Z","object_id":{"id":2564,"is_a":["categorization","keyword","keyword_audience"],"name":"zotonic_topic_backend_developer","title":"Backend developer","uri":"https:\/\/zotonic.com\/id\/2564"},"seq":2},{"created":"2026-10-07T11:13:45Z","object_id":{"id":2626,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_controller","title":"Controller","uri":"https:\/\/zotonic.com\/id\/2626"},"seq":3},{"created":"2026-10-07T11:13:45Z","object_id":{"id":2676,"is_a":["categorization","keyword","keyword_technology"],"name":"zotonic_topic_http","title":"HTTP","uri":"https:\/\/zotonic.com\/id\/2676"},"seq":4}],"predicate":{"id":308,"is_a":["meta","predicate"],"name":"subject","title":{"_type":"trans","tr":{"en":"Keyword"}},"uri":"http:\/\/purl.org\/dc\/elements\/1.1\/subject"}}},"id":1540,"is_a":["text","documentation","developerguide"],"links":[{"rel":"self","target":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1540"},{"rel":"hub","target":"https:\/\/zotonic.com\/.zotonic\/websub"}],"medium":null,"medium_url":null,"name":"doc_developerguide_controllers","page_url":{"en":"https:\/\/zotonic.com\/docs\/1540\/add-an-http-controller","x-default":"https:\/\/zotonic.com\/docs\/1540\/add-an-http-controller"},"preview_url":null,"resource":{"body":{"_type":"trans","tr":{"en":"<p>Use <code>controller_template<\/code> for a page that only renders a template. For a public, read-only plain-text endpoint, create <code>src\/controllers\/controller_garden_hello.erl<\/code> in the active Garden application:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">-module(controller_garden_hello).\n-export([content_types_provided\/1, process\/4]).\n\n-spec content_types_provided(Context) -&gt; {Types, Context}\n    when Context :: z:context(), Types :: list().\ncontent_types_provided(Context) -&gt;\n    {[{&lt;&lt;&quot;text&quot;&gt;&gt;, &lt;&lt;&quot;plain&quot;&gt;&gt;, []}], Context}.\n\n-spec process(Method, Accepted, Provided, Context) -&gt; {Body, Context}\n    when Method :: binary(), Accepted :: term(), Provided :: term(),\n         Context :: z:context(), Body :: binary().\nprocess(_Method, _Accepted, _Provided, Context) -&gt;\n    {&lt;&lt;&quot;Welcome to the garden&quot;&gt;&gt;, Context}.\n<\/code><\/pre>\n<p>Add a rule to the application&#39;s <code>priv\/dispatch\/garden<\/code> list:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">{garden_hello, [&quot;garden-hello&quot;], controller_garden_hello, []}\n<\/code><\/pre>\n<p>Compile, refresh discovery, and request <code>\/garden-hello<\/code> on the site&#39;s hostname. Expect a plain-text response containing the greeting. Check dispatch if it returns another page. The rule above is one tuple inside the dispatch list, not an entire dispatch file.<\/p>\n<p>This example deliberately returns public constant text. Private data needs explicit authorization callbacks and model checks; a write endpoint also needs method handling, input validation, and protection against unauthorized requests. Consult <a href=\"\/id\/1537\" class=\"doc-reference doc-reference-controller\"><code>controller#controller_template<\/code><\/a> for a built-in alternative and <a href=\"\/id\/1875\" class=\"doc-reference doc-reference-controller\"><code>controller#controller_api<\/code><\/a> for model-based HTTP access.<\/p>"}},"category_id":{"id":317,"is_a":["meta","category"],"name":"developerguide","title":"Developer guide","uri":"https:\/\/zotonic.com\/id\/developerguide"},"content_group_id":{"id":339,"is_a":["meta","content_group"],"name":"default_content_group","title":{"_type":"trans","tr":{"en":"Default Content Group"}},"uri":"https:\/\/zotonic.com\/id\/default_content_group"},"created":"2020-05-30T05:47:25Z","creator_id":{"id":336,"is_a":["person","robot"],"name":"gitbot","title":"Git","uri":"https:\/\/zotonic.com\/id\/336"},"doc_editorial_bundle":true,"doc_editorial_edges":{"hasreference":[1537,1875],"relation":[1536,2940,2966],"subject":[2554,2564,2626,2676]},"github_url":"https:\/\/github.com\/zotonic\/zotonic\/tree\/master\/doc\/developer-guide\/controllers.rst","is_authoritative":true,"is_dependent":false,"is_featured":false,"is_protected":false,"is_published":true,"is_unfindable":false,"language":["en"],"modified":"2026-10-07T11:13:56Z","modifier_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"name":"doc_developerguide_controllers","pivot_geocode":null,"pivot_location_lat":null,"pivot_location_lng":null,"privacy":0,"publication_end":"9999-06-01T00:00:00Z","publication_start":"2022-02-15T10:01:23Z","slug":"add-an-http-controller","summary":{"_type":"trans","tr":{"en":"Use controller_template when a dispatch rule only needs to render a template. Write a custom controller when the endpoint needs additional request processing or response behavior."}},"title":{"_type":"trans","tr":{"en":"Add an HTTP controller"}},"title_slug":{"_type":"trans","tr":{"en":"add-an-http-controller"}},"tz":"UTC","uri":null,"version":42,"visible_for":0},"uri":"https:\/\/zotonic.com\/id\/1540","uri_template":"https:\/\/zotonic.com\/id\/:id","websub":{"hub":"https:\/\/zotonic.com\/.zotonic\/websub","topic":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1540"}},"status":"ok"}