Make WordPress Core

Opened 11 years ago

Closed 10 years ago

#35580 closed enhancement (fixed)

Include auto-discovery header on REST responses

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

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 11 years ago.
35580.2.diff (1.5 KB ) - added by rachelbaker 10 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.


11 years ago

#2 @danielbachhuber
11 years ago

  • Owner set to joehoyle
  • Status newassigned

#3 @danielbachhuber
11 years ago

Header should be included on admin responses too

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


11 years ago

#5 @rmccue
11 years ago

  • Owner changed from joehoyle to rmccue
  • Status assignedreviewing

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


11 years ago

#7 @kirasong
11 years ago

  • Milestone 4.5Future Release

Punting this. Too late for 4.5 beta.

#8 @danielbachhuber
10 years ago

  • Milestone Future Release4.6

@rmccue Can you land this pretty please?

#9 @rachelbaker
10 years ago

  • Owner changed from rmccue to rachelbaker

#10 @rachelbaker
10 years ago

@danielbachhuber Picking this up to try and land in 4.6

@rachelbaker
10 years ago

Added unit test

#11 @rachelbaker
10 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
10 years ago

  • Keywords commit added

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


10 years ago

#14 @danielbachhuber
10 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
10 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
10 years ago

  • Resolutionfixed
  • Status reviewingclosed

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.