Add SSH Key Management
This commit is contained in:
parent
ef76844922
commit
bcd1805001
62 changed files with 1004 additions and 188 deletions
|
|
@ -6,9 +6,23 @@ import (
|
|||
)
|
||||
|
||||
// DefaultFieldTemplate is the default template to render fields.
|
||||
var DefaultFieldTemplate = template.Must(template.New("").Parse(`<input type="{{.Type}}" value="{{.Value}}" name="{{.Name}}" placeholder={{.Placeholder}}{{if .Autocomplete }} autocomplete="{{.Autocomplete}}{{end}}>`))
|
||||
var DefaultFieldTemplate = template.Must(template.New("").Parse(`
|
||||
{{ if (eq .Type "textarea" )}}
|
||||
<textarea name="{{.Name}}" id="{{.Name}}" placeholder="{{.Placeholder}}"{{if .Autocomplete }} autocomplete="{{.Autocomplete}}" {{end}}>{{.Value}}</textarea>
|
||||
{{ else }}
|
||||
<input type="{{.Type}}" value="{{.Value}}" name="{{.Name}}" placeholder={{.Placeholder}}{{if .Autocomplete }} autocomplete="{{.Autocomplete}}{{end}}>
|
||||
{{ end }}`))
|
||||
|
||||
var PureCSSFieldTemplate = template.Must(template.New("").Parse(`
|
||||
<div class="pure-control-group"><label for="{{.Name}}">{{.Label}}</label><input type="{{.Type}}" value="{{.Value}}" name="{{.Name}}" id="{{.Name}}" placeholder="{{.Placeholder}}"{{if .Autocomplete }} autocomplete="{{.Autocomplete}}" {{end}}></div>`))
|
||||
|
||||
<div class="pure-control-group">
|
||||
<label for="{{.Name}}">{{.Label}}</label>
|
||||
{{ if (eq .Type "textarea" )}}
|
||||
<textarea name="{{.Name}}" id="{{.Name}}" placeholder="{{.Placeholder}}"{{if .Autocomplete }} autocomplete="{{.Autocomplete}}" {{end}}>{{.Value}}</textarea>
|
||||
{{ else }}
|
||||
<input type="{{.Type}}" value="{{.Value}}" name="{{.Name}}" id="{{.Name}}" placeholder="{{.Placeholder}}"{{if .Autocomplete }} autocomplete="{{.Autocomplete}}" {{end}}>
|
||||
{{ end }}
|
||||
</div>`))
|
||||
|
||||
// Field represents a field inside a form.
|
||||
type Field struct {
|
||||
|
|
|
|||
|
|
@ -27,4 +27,6 @@ const (
|
|||
Url InputType = "url"
|
||||
Week InputType = "week"
|
||||
Datetime InputType = "datetime"
|
||||
|
||||
Textarea InputType = "textarea" // special
|
||||
)
|
||||
|
|
|
|||
14
pkg/httpx/wrap.go
Normal file
14
pkg/httpx/wrap.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package httpx
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// WithContextWrapper generates a new handler that wraps the context of each request with the wrapper function.
|
||||
func WithContextWrapper(handler http.Handler, wrapper func(context.Context) context.Context) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
r = r.WithContext(wrapper(r.Context()))
|
||||
handler.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue