0
votes

I was wondering if $http can send ajax request to the server using the LINK/UNLINK method (like POST, GET, PUT, PATCH..). I already search in the AngularJS documentation and only found this list of available methods:

  • $http.get
  • $http.head
  • $http.post
  • $http.put
  • $http.delete
  • $http.jsonp
  • $http.patch

AngularJs $http doc

LINK method is really useful when you want to make relation only between resources, and it is a really shame if it is missing. If someone know how to do this request, can give me an example please?

Examples of LINK/UNLINK method:

There exists a broad range of possible use cases for the LINK and UNLINK methods. The examples that follow illustrate a subset of those cases.

Example 1: Creating two separate links between an image and the profiles of two people associated with the image:

  LINK /images/my_dog.jpg HTTP/1.1
  Host: example.org
  Link: <http://example.com/profiles/joe>; rel="tag"
  Link: <http://example.com/profiles/sally>; rel="tag"

Example 2: Removing an existing Link relationship between two resources:

  UNLINK /images/my_dog.jpg HTTP/1.1
  Host: example.org
  Link: <http://example.com/profiles/sally>; rel="tag"

Here are some documentation about LINK method:

http://www.w3.org/Protocols/HTTP/Methods/Link.html

http://tools.ietf.org/id/draft-snell-link-method-01.html#RFC5988

2
Worked the solution provided by @maurycy? I can't directly test it since I'm more from the backend side, but I'm developing an internal API and I don't want to be a stopper because my "aesthetic" preferences.castarco

2 Answers

0
votes

you can also use $http without those short methods, this might work, if doesn't check if there is a request with OPTIONS method

$http({method: 'LINK', url: '/someUrl'}).
  success(function(response){
    //do something fancy
  })
0
votes

No, sorry, by default AngularJS does not provide anyway to request with LINK.

So you've options :

  • change verb.
  • put another server between you and your targeted server to do a proxy.
  • use restangular which allows to use LINK.