Things I did while unable to commit
- Log rotation - Execution cancellation - HTTP redirect, error functions - Changed naming of document parsing/loading functions
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
package http
|
||||
|
||||
import "net/http"
|
||||
import "net/url"
|
||||
import "net/http"
|
||||
import "html/template"
|
||||
import "git.tebibyte.media/sashakoshka/step"
|
||||
import shttp "git.tebibyte.media/sashakoshka/step/http"
|
||||
|
||||
var _ step.FuncProvider = new(Provider)
|
||||
|
||||
@@ -23,6 +24,8 @@ func (this *Provider) FuncMap () template.FuncMap {
|
||||
"statusText": http.StatusText,
|
||||
"parseQuery": funcParseQuery,
|
||||
"parseForm": funcParseForm,
|
||||
"error": funcError,
|
||||
"redirect": funcRedirect,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,8 +38,22 @@ func funcParseQuery (query string) url.Values {
|
||||
return values
|
||||
}
|
||||
|
||||
func funcError (status int, message any) (string, error) {
|
||||
return "", shttp.Error {
|
||||
Status: status,
|
||||
Message: message,
|
||||
}
|
||||
}
|
||||
|
||||
func funcRedirect (res shttp.WrappedResponseWriter, status int, pat string) (string, error) {
|
||||
// TODO remove parameters
|
||||
res.Header.Add("Location", pat)
|
||||
res.WriteHeader(status)
|
||||
return "", step.ErrExecutionCanceled
|
||||
}
|
||||
|
||||
func funcParseForm (req *http.Request) url.Values {
|
||||
// FIXME there is already a parse form method lol this can be removed
|
||||
err := req.ParseForm()
|
||||
if err != nil { return nil }
|
||||
return req.Form
|
||||
|
||||
Reference in New Issue
Block a user