1
0
Fork 0
mirror of https://git.sr.ht/~adnano/go-gemini synced 2024-05-30 03:26:15 +02:00

Remove Input function

This commit is contained in:
Adnan Maolood 2020-12-18 00:25:06 -05:00
parent 824887eab9
commit 35836f2ff7
2 changed files with 2 additions and 22 deletions

View File

@ -74,8 +74,8 @@ func changeUsername(w *gemini.ResponseWriter, r *gemini.Request) {
return
}
username, ok := gemini.Input(r)
if !ok {
username, err := gemini.QueryUnescape(r.URL.RawQuery)
if err != nil || username == "" {
w.WriteHeader(gemini.StatusInput, "Username")
return
}

View File

@ -335,23 +335,3 @@ type ResponderFunc func(*ResponseWriter, *Request)
func (f ResponderFunc) Respond(w *ResponseWriter, r *Request) {
f(w, r)
}
// Input returns the request query.
// If the query is invalid or no query is provided, ok will be false.
//
// Example:
//
// input, ok := gemini.Input(req)
// if !ok {
// w.WriteHeader(gemini.StatusInput, "Prompt")
// return
// }
// // ...
//
func Input(r *Request) (query string, ok bool) {
if r.URL.ForceQuery || r.URL.RawQuery != "" {
query, err := url.QueryUnescape(r.URL.RawQuery)
return query, err == nil
}
return "", false
}