Skip to content
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

Allow cross domain AJAX Requests #3

Closed
bbalet opened this issue Dec 26, 2013 · 1 comment
Closed

Allow cross domain AJAX Requests #3

bbalet opened this issue Dec 26, 2013 · 1 comment

Comments

@bbalet
Copy link

bbalet commented Dec 26, 2013

If you want to distribute your lib as a standalone web server (A), then you have to take into account that other developpers using it might have their own web server (B) in their go app. Please patch you lib to allow web pages served by B to request server A.

func Search(w http.ResponseWriter, r *http.Request) {
    vars := mux.Vars(r)
    query := vars["query"]

    searchResult := CleoSearch(m.iIndex, m.fIndex, query)
    sort.Sort(ByScore{searchResult})
    myJson, _ := json.Marshal(searchResult)

    // allow cross domain AJAX requests
        w.Header().Set("Access-Control-Allow-Origin", "*")
    fmt.Fprintf(w, string(myJson))
}
@jamra
Copy link
Owner

jamra commented Dec 26, 2013

Deemed unnecessary by #6

@jamra jamra closed this as completed Dec 26, 2013
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

No branches or pull requests

2 participants