Overview

I created a custom REST resource by following the instructions below.

https://www.drupal.org/docs/drupal-apis/restful-web-services-api/custom-rest-resources

By following the above article, I was able to obtain a JSON result from the following URL.

/demo_rest_api/demo_resource

{}"message":"Hello,thisisarestservice"

REST UI Module

The above article included the following note:

If you are using the REST UI contrib module, you should now be able to see it in the list of available endpoints and you should be able to configure the GET method.

For this, I enabled the REST UI module by referring to the following article.

https://www.studio-umi.jp/blog/12/357

Prototyping the IIIF Presentation API

Next, I worked on creating JSON for each content item. Specifically, I configured it so that accessing the path /iiif/3/{id}/manifest would output information based on the IIIF Presentation API v3.

The following article was helpful.

https://medium.com/drupaljournal/create-custom-rest-resource-for-get-and-post-method-in-drupal-8-e445330be3ff

Create a file as follows. In this example, the title is retrieved from $node. By extending this approach, information from other fields can also be retrieved.

<nuuuuc}?asssslpmeeeeap}heA@supsDDDDnRsbi}rprrrrneilu}Ro@lfeauuuuosdarPebpi$i}rtcppppttbi"rsjaNc(nfeueaaaaaR=e_cepero$o$]$i}rtrlllltelpasocadfiLd(m;rfeunD\\\\is"anentmeudoe$ae$trrnnrrooi=tond.n)annsC(runnuooeenuihnts$icd=oi"""]po$erepddssri@siaidt{df@tlonrsnnwaeettfcfTcttd.inNeecyanfepel\\\\oe_r=aioooosopbsiso$wR\ENPRr(palondditnee"]egpnrednolern{"nGeent"lnuoseRsetdusges3Eg:s=e"o=rneseomiegoesl=Te:tx=nes-psuotIiuteaetla[t>=e$ne>oor_ynnrnt"xr(on">"necanucr\t\cmti/te$ac"owaidsreeNeReeaoieqide=M[=dcndecRsoreRttninud(o>a>eRhsC;eetdfsehi(ide)$fn-eitaRs_eaosoo"fssi"i[>snacepa;cupdnI/t{dNhfgognhsopero_I3Rs)oteeucepni;cn3I/e.;dtstrfeaos\es"F{sept(coobnePBe,ioII:""erfls(la;Pdutn/,tRee'usr}rt/ierCD(Agee/cweitseae'ri;smeirilpscpAtneaBlfieouheri\nnalaf"nlentcrtisc.)stadileaferei[esbecestee)o0(lnltis{t/]$eceI\otu{a-mRydrn"rp>ae(denigns$oisA/eipnesoPsptfoosuIer(endnrrre"sse\ecvisvte)'qe3aea)I;tu;"lnl;ni)ituter,zaeexeet"ridi)fs'jo-at,sn>c'o/ge,4n3e)0/t40fcV{0)ooa0;rnl)mtu;aeetx(t)o.fjsnoond"e,

Granting Permissions

On the following page, check the box for Anonymous user to allow access from external sources.

/admin/people/permissions#module-rest

As a result, by accessing a URL like /iiif/3/5070/manifest, even non-logged-in users can retrieve a JSON file like the following.

{}"""}@tlcya"]opbnneeo"t"lne:"ex:"t":""M{:a[n"ihftetspt:"/,/iiif.io/api/presentation/3/context.json",

Summary

I introduced an example of creating custom REST resources in Drupal. I hope this serves as a reference when creating custom resources.

I also plan to continue implementing the IIIF Presentation API and create a module similar to Omeka S’s IIIF Server.