Giter Site home page Giter Site logo

accent's People

Contributors

amcvitty avatar anthonator avatar boon-wego avatar bournerj avatar dependabot-preview[bot] avatar dependabot[bot] avatar maxsalven avatar szajbus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

accent's Issues

camelCase and PascalCase

Why is it that using Accent.Transformer.PascalCase converts the first letter of key to small and Accent.Transformer.CamelCase with capital? It should be the other way around I think.

Ways to ignore or support Plug.upload on request

There seems to be an issue with Plug.upload.

Following the guide on file upload, shows error
image

This is whats on my router.ex

  pipeline :api do
    plug :accepts, ["json"]

    plug Plug.Parsers,
      parsers: [:urlencoded, :json],
      pass: ["*/*"],
      json_decoder: Jason

    plug Accent.Plug.Request # Removing this line will fix the issue
    
    plug Accent.Plug.Response,
      default_case: Accent.Case.Camel,
      header: "x-accent",
      supported_cases: %{"pascal" => Accent.Case.Pascal},
      json_codec: Jason
  end

Add default response case transformation

Hi

It would be nice to allow setting a default casing for response payloads, even without the client setting the accent header.

In my situation I'd like to always send all responses as camelcase

get_resp_header in before_send_callback instead of get_req_header?

Just wondering, responses.ex on before_send_callback

https://github.com/sticksnleaves/accent/blob/9f5011677827d98e2cedf976f4120132b719004c/lib/accent/plugs/response.ex#L71

Should this be a

get_req_header("content-type")

As on the do_call? uses get_req_header("content-type") on https://github.com/sticksnleaves/accent/blob/9f5011677827d98e2cedf976f4120132b719004c/lib/accent/plugs/response.ex#L99

I've tried to change it and all the tests are passing.

Should apply Accent.Plug.Response without specifying Content-Type: application/json

Would it be possible to apply the Accent.Plug.Response without having a request with Content-Type: application/json header.

For file upload uses cases, the request header has Content-Type: multipart/form-data, I should expect the result be transform into json in camel case.

A configuration would look like this:

pipeline :uploads do
  plug Accent.Plug.Response,
    default_case: Accent.Case.Camel,
    json_codec: Jason
end

scope "/uploads", StackedWeb do
  pipe_through :uploads

  resources "/files", FileController, only: [:create, :show]
end

I've been using propercase, and it does handle this kind of use case.

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.