Skip to content

Commit

Permalink
Remove self link support from Halcyon.MVC until Halcyon package is pu…
Browse files Browse the repository at this point in the history
…blished
  • Loading branch information
johncmckim committed May 9, 2016
1 parent 6205ed2 commit 529ba51
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/Halcyon.Mvc/HAL/ControllerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ public static class ControllerExtensions {
return hyperMedia.ToActionResult(controller, statuscode);
}

public static IActionResult HAL<T>(this Controller controller, T model, Link link, string relativeLinkBase = "~/", bool addSelfLinkIfNotExists = true, HttpStatusCode statuscode = HttpStatusCode.OK) {
return controller.HAL(model, new Link[] { link }, relativeLinkBase, addSelfLinkIfNotExists, statuscode);
public static IActionResult HAL<T>(this Controller controller, T model, Link link, string relativeLinkBase = "~/", HttpStatusCode statuscode = HttpStatusCode.OK) { // bool addSelfLinkIfNotExists = true,
return controller.HAL(model, new Link[] { link }, relativeLinkBase, statuscode); // addSelfLinkIfNotExists,
}

public static IActionResult HAL<T>(this Controller controller, T model, IEnumerable<Link> links, string relativeLinkBase = "~/", bool addSelfLinkIfNotExists = true, HttpStatusCode statuscode = HttpStatusCode.OK) {
public static IActionResult HAL<T>(this Controller controller, T model, IEnumerable<Link> links, string relativeLinkBase = "~/", HttpStatusCode statuscode = HttpStatusCode.OK) { // bool addSelfLinkIfNotExists = true,
string linkBase = GetLinkBase(controller, relativeLinkBase);

var response = new HALResponse(model, new HALModelConfig {
LinkBase = linkBase
})
.AddLinks(links);

if(addSelfLinkIfNotExists) {
response.AddSelfLinkIfNotExists(controller.Request);
}
//if(addSelfLinkIfNotExists) {
// response.AddSelfLinkIfNotExists(controller.Request);
//}

return response.ToActionResult(controller, statuscode);
}
Expand Down
12 changes: 6 additions & 6 deletions src/Halcyon.Mvc/HAL/HALResponseExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
namespace Halcyon.Web.HAL {
public static class HALResponseExtensions {

public static HALResponse AddSelfLinkIfNotExists(this HALResponse response, HttpRequest request) {
if(!response.HasSelfLink()) {
response.AddSelfLink(request);
}
//public static HALResponse AddSelfLinkIfNotExists(this HALResponse response, HttpRequest request) {
// if(!response.HasSelfLink()) {
// response.AddSelfLink(request);
// }

return response;
}
// return response;
//}

public static HALResponse AddSelfLink(this HALResponse response, HttpRequest request) {
var selfLink = new Link(Link.RelForSelf, request.Path, method: request.Method);
Expand Down
3 changes: 3 additions & 0 deletions src/Halcyon.sln
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Halcyon.Mvc", "Halcyon.Mvc\Halcyon.Mvc.xproj", "{61301A50-41DB-43E0-AA67-867AB52B0CA0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7CAE2965-EABD-493F-8DF4-BF2EAE886FF5}"
ProjectSection(SolutionItems) = preProject
global.json = global.json
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Halcyon.Tests.SelfHost.Mvc", "Halcyon.Tests.SelfHost.Mvc\Halcyon.Tests.SelfHost.Mvc.xproj", "{09471327-10FB-4308-8F33-91A9605FD230}"
EndProject
Expand Down

0 comments on commit 529ba51

Please sign in to comment.