@@ -6,17 +6,23 @@ import (
66 "io"
77 "net/http"
88 "regexp"
9+ "strings"
910
1011 "github.com/AlexxIT/go2rtc/pkg/tcp"
1112 "github.com/expr-lang/expr"
1213)
1314
14- func newRequest (method , url string , headers map [string ]any ) (* http.Request , error ) {
15+ func newRequest (method , url string , headers map [string ]any , body string ) (* http.Request , error ) {
16+ var rd io.Reader
17+
1518 if method == "" {
1619 method = "GET"
1720 }
21+ if body != "" {
22+ rd = strings .NewReader (body )
23+ }
1824
19- req , err := http .NewRequest (method , url , nil )
25+ req , err := http .NewRequest (method , url , rd )
2026 if err != nil {
2127 return nil , err
2228 }
@@ -55,7 +61,8 @@ var Options = []expr.Option{
5561 options := params [1 ].(map [string ]any )
5662 method , _ := options ["method" ].(string )
5763 headers , _ := options ["headers" ].(map [string ]any )
58- req , err = newRequest (method , url , headers )
64+ body , _ := options ["body" ].(string )
65+ req , err = newRequest (method , url , headers , body )
5966 } else {
6067 req , err = http .NewRequest ("GET" , url , nil )
6168 }
0 commit comments