feat: complete API-driven projects with infrastructure and business acceptance

This commit is contained in:
2026-09-23 17:33:50 +08:00
parent 04a1f7999d
commit 2c74dc0859
137 changed files with 11926 additions and 105 deletions

View File

@@ -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)