feat: complete API-driven projects with infrastructure and business acceptance
This commit is contained in:
@@ -14,10 +14,11 @@ import (
|
||||
)
|
||||
|
||||
type Signer struct {
|
||||
store Store
|
||||
base *url.URL
|
||||
secret []byte
|
||||
now func() time.Time
|
||||
store Store
|
||||
base *url.URL
|
||||
secret []byte
|
||||
now func() time.Time
|
||||
uploadPolicy *UploadPolicy
|
||||
}
|
||||
|
||||
func NewSigner(store Store, baseURL string, secret []byte) (*Signer, error) {
|
||||
@@ -51,6 +52,10 @@ func (s *Signer) PresignGet(ctx context.Context, key string, ttl time.Duration)
|
||||
// ServeHTTP serves signed downloads as attachments. Issue links only after
|
||||
// authorization; possession of an unexpired URL grants access to its object.
|
||||
func (s *Signer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method == http.MethodPut && s.uploadPolicy != nil {
|
||||
s.serveUpload(w, r)
|
||||
return
|
||||
}
|
||||
if r.Method != "GET" && r.Method != "HEAD" {
|
||||
w.Header().Set("Allow", "GET, HEAD")
|
||||
http.Error(w, "method not allowed", 405)
|
||||
|
||||
Reference in New Issue
Block a user