Code Monkey home page Code Monkey logo

webapi.hypermedia's Introduction

WebApi.Hypermedia

This project was inspired by the WebApi.Hal (https://github.com/JakeGinnivan/WebApi.Hal) opensource project.

The problem this project is trying to solve here is:

Given an ASP.NET Web Api 2.x project...

  1. I want to be able to return just a plain old DTO from my controller action.
  2. I want to have some default metadata configured that is associated with my DTO.
  3. I want to be able to add/modify the metadata associated with my DTO contextually in my controller action.
  4. I want to be able to plug-in different Formatters to support different Hypermedia formats over time.
  5. I only want to return hypermedia format (with metadata) if the Accept header matches a registered formatter. Otherwise, I want the plain old DTO returned.

A custom ActionFilterAttribute (HypermediaFilter) can solve # 1 by intercepting the Request and replacing it with a HypermediaObject.

A configuration registration mechanism similar to the appenders in WebApi.Hal can solve # 2.

Storing extra Links metadata in the Request.Properties (made easier with extension methods) can solve # 3. Then, the custom ActionFilterAttribute can merge the default metadata with the contextual metadata from the Request when it encapsulates the DTO in the HypermediaObject.

By keeping the metadata fairly generic and not tying it directly to HAL or any other specific Hypermedia format standard, we can support # 4.

By checking the Accept header inside the custom ActionFilterAttribute, we can support # 5.

webapi.hypermedia's People

Contributors

chrisaswain avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.