Giter VIP home page Giter VIP logo

Comments (4)

ngcammayo avatar ngcammayo commented on June 23, 2024

Sample format would be like this:

[
{
"meta_total_count": 10,
"meta_filter_count": 0,
"meta_response":
{
"id": "1",
"code": "est",
"name": "Est et.",
"status": "0",
"created_by": "minus",
"updated_by": null,
"created_at": "2014-04-19 02:03:37",
"updated_at": "2014-04-19 02:03:37",
"deleted_at": null
}
}
]

from laravel-api-handler.

marcelgwerder avatar marcelgwerder commented on June 23, 2024

I thought a lot about this and I decided to first support the meta information in the http headers. However I may indeed add this optional feature in the future. There are multiple ways to do this.
I could support an additional parameter in getResponse() or an option in the package config which allows the developer to decide what he wants. Or use a flag like _config=envelope where the client can decide In which form he wants the data.

This of course isn't implemented right now. With the tools available right now you can still manually implement an envelope. This is however not that clean but it works:

$result = ApiHandler::parseMultiple($foo, array('foo', 'bar'));
$builder = $result->getBuilder();
$metaProviders = $result->getMetaProviders();
$response = array();

foreach($metaProviders as $provider) {
    if($provider->getTitle() == 'Meta-Total-Count') $response['meta_total_count'] = $provider->get();    
    else if($provider->getTitle() == 'Meta-Filter-Count') $response['meta_filter_count'] = $provider->get();
}

$response['data'] = $builder->get();

return $response; 

from laravel-api-handler.

ngcammayo avatar ngcammayo commented on June 23, 2024

Thanks, it just shows the flexibility that you have implemented this handler in a way to make it open for modification.

Once again thank you for considering my request.

from laravel-api-handler.

marcelgwerder avatar marcelgwerder commented on June 23, 2024

Lets keep this issue open. I'll close it when there is a more sophisticated solution.

from laravel-api-handler.

Related Issues (20)

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.