http-rs / http-types

Common types for HTTP operations
https://docs.rs/http-types
Apache License 2.0
200 stars 83 forks source link

Add `content::ContentLocation` header #256

Closed pepoviola closed 3 years ago

pepoviola commented 3 years ago

Hi All, this is an attempt to make my small contribution to this awesome project 🙌 . This PR is inspired by https://github.com/http-rs/http-types/pull/253 ( I try to following the same approach ) and also ref to one of the headers listed on #99.

I have some question related to the field for the ContentLocation struct. Is ok to be a String and parse with the Url crate or is better to use another type ( like to be directly an url and just format in the value ) ?

I'm new to rust and my code could be partial ( or totally 😄 ) wrong, so any feedback is welcome.

yoshuawuyts commented 3 years ago

Also ref #99

pepoviola commented 3 years ago

Hi @yoshuawuyts, Thanks for the feedback! I make some of the required changes ( the small ones ) and also change the struct to use Url type internally.

I'm not sure if this is ok, since an invalid base_url should return a 400 error right?

        let base = base_url.try_into().expect("Could not convert into a valid url");
        let url = base.join(value.as_str().trim()).status(400)?;

Again thanks for the feedback, and let me know if the approach isn't good.

pepoviola commented 3 years ago

Thanks @Fishrock123! I will open the pr for review 👍

pepoviola commented 3 years ago

awesome!, thanks for the guide and all the help!! 🙌