Skip to content

Allow static files to be published into final image for Go template #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 13, 2022

Conversation

alexellis
Copy link
Member

Signed-off-by: Alex Ellis (OpenFaaS Ltd) [email protected]

Description

Allow static files to be published into final image for Go template

How Has This Been Tested?

package function

import (
    "io/ioutil"
    "net/http"
)

func Handle(w http.ResponseWriter, r *http.Request) {

    data, err := ioutil.ReadFile("./static/file.txt")

    if err != nil {
        http.Error(w, err.Error(), http.StatusInternalServerError)
    }

    w.Write(data)
}

How are existing users impacted? What migration steps/scripts do we need?

This is a breaking change for existing users who rely on folder names such as templates or dataset.json within their published image.

Now, put these files into the static folder and read them from ./static/templates/index.html and so forth.

Checklist:

A note will be published in the openfaas docs repo for this new change.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
@alexellis alexellis merged commit d1aa33f into master Apr 13, 2022
@alexellis alexellis deleted the openfaasltd/static-files branch April 13, 2022 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants