Coder Social home page Coder Social logo

notbad4u / query_params Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 1.0 12 KB

Custom derive to automatically implement serialization to http query params for arbitrary structs.

License: MIT License

Rust 100.00%
query-params http-client rust custom-derive derive macros

query_params's People

Contributors

notbad4u avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

crackcomm

query_params's Issues

Working with url crate

Hi,
It's just idea.

There is a quite good url lib that could match your library.

There is a set_query method that near match your to_query_params().

Your generate ?sth=2 url accept Some("sth=2") (without ?). I think it would be nice to make your solution merged. Serialize structures with derive is nice future.

Problem occurs when your struct contains only Option and you can generate empty str.

let generated_query =  structure.to_query_params();
if generated_query.len() > 0 {      
      url.set_query(Some(&generated_query.as_str()[1..]));     
  }

I will link to this issue from url. Maybe sb will be interested and find a nice solution.

Encode values

This doesn't handle values containing special characters correctly, because it doesn't escape them. This is particularly problematic for & and =, since these will now be interpreted as separate parameters. This could lead to security vulnerabilities, similar to SQL-Injection or XSS.

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.