File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33 * @module capability-discovery
44 */
55const express = require ( 'express' )
6- const addLink = require ( './header' ) . addLink
76const util = require ( './utils' )
87
98const serviceConfigDefaults = {
@@ -31,26 +30,10 @@ function capabilityDiscovery () {
3130 var router = express . Router ( '/' )
3231
3332 // Advertise the server capability discover endpoint
34- router . options ( '*' , serviceEndpointHeader )
3533 router . get ( '/.well-known/solid' , serviceCapabilityDocument ( serviceConfigDefaults ) )
3634 return router
3735}
3836
39- /**
40- * Handles advertising the server capability endpoint (adds a Link Relation
41- * header of type `service`, points to the capability document).
42- * To be used with OPTIONS requests.
43- * @method serviceEndpointHeader
44- * @param req
45- * @param res
46- * @param next
47- */
48- function serviceEndpointHeader ( req , res , next ) {
49- let serviceEndpoint = `${ util . uriBase ( req ) } /.well-known/solid`
50- addLink ( res , serviceEndpoint , 'service' )
51- next ( )
52- }
53-
5437/**
5538 * Serves the service capability document (containing server root URL, including
5639 * any base path the user specified in config, server API endpoints, etc).
Original file line number Diff line number Diff line change 1+ const addLink = require ( '../header' ) . addLink
2+ const utils = require ( '../utils' )
3+
4+ module . exports = handler
5+
6+ function handler ( req , res , next ) {
7+ let serviceEndpoint = `${ utils . uriBase ( req ) } /.well-known/solid`
8+ addLink ( res , serviceEndpoint , 'service' )
9+ res . header ( 'Accept-Patch' , 'application/sparql-update' )
10+ next ( )
11+ }
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ var get = require('./handlers/get')
88var post = require ( './handlers/post' )
99var put = require ( './handlers/put' )
1010var del = require ( './handlers/delete' )
11+ var options = require ( './handlers/options' )
1112var patch = require ( './handlers/patch' )
1213var index = require ( './handlers/index' )
1314var errorPages = require ( './handlers/error-pages' )
@@ -32,6 +33,7 @@ function LdpMiddleware (corsSettings) {
3233 router . patch ( '/*' , acl . allow ( 'Append' ) , patch )
3334 router . put ( '/*' , acl . allow ( 'Write' ) , put )
3435 router . delete ( '/*' , acl . allow ( 'Write' ) , del )
36+ router . options ( '/*' , options )
3537
3638 // Errors
3739 router . use ( errorPages )
Original file line number Diff line number Diff line change @@ -106,6 +106,26 @@ describe('HTTP APIs', function () {
106106 . expect ( 204 , done )
107107 } )
108108
109+ describe ( 'Accept-Patch header' , function ( ) {
110+ it ( 'should be present for resources' , function ( done ) {
111+ server . options ( '/sampleContainer/example1.ttl' )
112+ . expect ( 'Accept-Patch' , 'application/sparql-update' )
113+ . expect ( 204 , done )
114+ } )
115+
116+ it ( 'should be present for containers' , function ( done ) {
117+ server . options ( '/sampleContainer/' )
118+ . expect ( 'Accept-Patch' , 'application/sparql-update' )
119+ . expect ( 204 , done )
120+ } )
121+
122+ it ( 'should be present for non-rdf resources' , function ( done ) {
123+ server . options ( '/sampleContainer/solid.png' )
124+ . expect ( 'Accept-Patch' , 'application/sparql-update' )
125+ . expect ( 204 , done )
126+ } )
127+ } )
128+
109129 it ( 'should have an empty response' , function ( done ) {
110130 server . options ( '/sampleContainer/example1.ttl' )
111131 . expect ( emptyResponse )
You can’t perform that action at this time.
0 commit comments