Skip to content

Change URL protocol in response data based on whether the request was made over HTTPS #66

@mulchy

Description

@mulchy

Hi!

First, I would like to say that I love this project and I use to teach my students about APIs. It's awesome!

Second, I have a small feature request. Could we detect on the server whether the user-agent made the request over HTTPS and update any URLs in the response data to use HTTPS as their protocol?

Currently, running curl https://swapi.co/api/films/ results in

{
    "count": 7,
    "next": null,
    "previous": null,
    "results": [{
        "title": "A New Hope",
        ...
        "species": ["http://swapi.co/api/species/3/", "http://swapi.co/api/species/2/", "http://swapi.co/api/species/1/"],
        "created": "2015-04-17T06:51:30.504780Z",
        "edited": "2015-12-17T14:31:47.617768Z",
        "url": "http://swapi.co/api/films/7/"
    }]
}

I am proposing a desired output of

{
    "count": 7,
    "next": null,
    "previous": null,
    "results": [{
        "title": "A New Hope",
        ...
        "species": ["https://swapi.co/api/species/3/", "https://swapi.co/api/species/2/", "https://swapi.co/api/species/1/"],
        "created": "2015-04-17T06:51:30.504780Z",
        "edited": "2015-12-17T14:31:47.617768Z",
        "url": "https://swapi.co/api/films/7/"
    }]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions