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

error running examples (firefox only?) #6

Open
splace opened this issue May 4, 2022 · 0 comments
Open

error running examples (firefox only?) #6

splace opened this issue May 4, 2022 · 0 comments

Comments

@splace
Copy link

splace commented May 4, 2022

when trying example i get error.

image

this is due to firefox being a json browser and the examples are returning plain/text but saying they are returning json.

writer.Header().Set("Content-Type", "application/json")
q := request.URL.Query()
query := q.Get("q")
if query != "" {
	var (
		ast *parser.SelectTree
	)

	p := &parser.Parser{}
	if p.GetSQLType(query) != parser.SELECT {
		_, _ = fmt.Fprintf(writer, "not a SELECT statement")
		return
	}

for all the error printing lines, this will fix;

example;
http.Error(writer, "not a SELECT statement", http.StatusBadRequest)
from
_, _ = fmt.Fprintf(writer, "not a SELECT statement")

but the data written will also have to be converted to json.

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

1 participant