Make WordPress Core

Opened 9 years ago

Closed 8 years ago

#35580 closed enhancement (fixed)

Include auto-discovery header on REST responses

Reported by: danielbachhuber's profile danielbachhuber Owned by: rachelbaker's profile rachelbaker
Milestone: 4.6 Priority: normal
Severity: normal Version:
Component: REST API Keywords: has-patch has-unit-tests commit
Focuses: Cc:

Description

Adds Link header to REST API responses:

Link: <http://wordpress-develop.dev/wp-json/>; rel="https://api.w.org/"

When a client is attempting to auto-discover the API with a HEAD request, WordPress should always include the Link header to orient the client.

Attachments (2)

35580.1.diff (702 bytes) - added by danielbachhuber 9 years ago.
35580.2.diff (1.5 KB) - added by rachelbaker 8 years ago.
Added unit test

Download all attachments as: .zip

Change History (18)

This ticket was mentioned in Slack in #core-restapi by danielbachhuber. View the logs.


9 years ago

#2 @danielbachhuber
9 years ago

  • Owner set to joehoyle
  • Status changed from new to assigned

#3 @danielbachhuber
9 years ago

Header should be included on admin responses too

This ticket was mentioned in Slack in #core by jorbin. View the logs.


9 years ago

#5 @rmccue
9 years ago

  • Owner changed from joehoyle to rmccue
  • Status changed from assigned to reviewing

This ticket was mentioned in Slack in #core by mike. View the logs.


9 years ago

#7 @kirasong
9 years ago

  • Milestone changed from 4.5 to Future Release

Punting this. Too late for 4.5 beta.

#8 @danielbachhuber
8 years ago

  • Milestone changed from Future Release to 4.6

@rmccue Can you land this pretty please?

#9 @rachelbaker
8 years ago

  • Owner changed from rmccue to rachelbaker

#10 @rachelbaker
8 years ago

@danielbachhuber Picking this up to try and land in 4.6

@rachelbaker
8 years ago

Added unit test

#11 @rachelbaker
8 years ago

  • Keywords has-unit-tests added

In 35580.2.diff I added a unit test to check the presence of the Link header. This looks good to me and unless @rmccue objects I can land this.

#12 @rachelbaker
8 years ago

  • Keywords commit added

This ticket was mentioned in Slack in #core by ocean90. View the logs.


8 years ago

#14 @danielbachhuber
8 years ago

@rachelbaker Ryan mentioned adding the header to /wp-admin/ requests too, which makes sense to me. Want to add that as well? Probably could happen in two separate commits.

#15 @rachelbaker
8 years ago

@danielbachhuber Including the link header for wp-admin requests could probably be done using rest_output_link_header, but I don't feel strongly this is needed (rest_output_link_header already is hooked into template_redirect also included in dispatched API requests). Of course @rmccue can add if he likes.

#16 @rachelbaker
8 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 37903:

REST API: Include auto-discovery Link header when serving API requests.

The Link header allows clients to verify if a site has made the REST API available, as well as indicating how to access it.

Props danielbachhuber.
Fixes #35580.

Note: See TracTickets for help on using tickets.