diff --git a/.golangci.yml b/.golangci.yml index f3c0e06..13a1ae6 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -24,7 +24,7 @@ linters: - maligned - nilnil - nlreturn - - scopelint + - scopelint - testpackage - varnamelen - wrapcheck @@ -35,19 +35,19 @@ linters-settings: godot: capital: true ireturn: - allow: "error,empty,anon,stdlib,.*(or|er)$,github.com/99designs/gqlgen/graphql.Marshaler,github.com/dstotijn/hetty/pkg/api.QueryResolver,github.com/dstotijn/hetty/pkg/filter.Expression" - + allow: "error,empty,anon,stdlib,.*(or|er)$,github.com/dstotijn/hetty/pkg/filter.Expression" + issues: exclude-rules: - linters: - - gosec + - gosec # Ignore SHA1 usage. text: "G(401|505):" - linters: - - wsl + - wsl # Ignore cuddled defer statements. text: "only one cuddle assignment allowed before defer statement" - linters: - - nlreturn + - nlreturn # Ignore `break` without leading blank line. - text: "break with no blank line before" \ No newline at end of file + text: "break with no blank line before" diff --git a/README.md b/README.md index 9cf4084..8905458 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ $ hetty --help Usage: hetty [flags] [subcommand] [flags] -Runs an HTTP server with (MITM) proxy, GraphQL service, and a web based admin interface. +Runs an HTTP server with (MITM) proxy and a web based admin interface. Options: --cert Path to root CA certificate. Creates file if it doesn't exist. (Default: "~/.hetty/hetty_cert.pem") diff --git a/buf.gen.yaml b/buf.gen.yaml new file mode 100644 index 0000000..d1891cc --- /dev/null +++ b/buf.gen.yaml @@ -0,0 +1,10 @@ +version: v2 +plugins: + - local: protoc-gen-go + out: pkg + opt: paths=source_relative + - local: protoc-gen-connect-go + out: pkg + opt: + - paths=source_relative + - package_suffix # Generate `*.connect.go` files next to `*.pb.go` files. diff --git a/buf.yaml b/buf.yaml new file mode 100644 index 0000000..8d0b2fa --- /dev/null +++ b/buf.yaml @@ -0,0 +1,12 @@ +version: v2 +modules: + - path: proto +lint: + use: + - STANDARD + except: + - PACKAGE_DIRECTORY_MATCH + - PACKAGE_VERSION_SUFFIX +breaking: + use: + - PACKAGE diff --git a/cmd/hetty/hetty.go b/cmd/hetty/hetty.go index 50c785c..e2bfdfb 100644 --- a/cmd/hetty/hetty.go +++ b/cmd/hetty/hetty.go @@ -22,7 +22,6 @@ import ( "go.etcd.io/bbolt" "go.uber.org/zap" - "github.com/dstotijn/hetty/pkg/api" "github.com/dstotijn/hetty/pkg/chrome" "github.com/dstotijn/hetty/pkg/db/bolt" "github.com/dstotijn/hetty/pkg/proj" @@ -45,7 +44,7 @@ var hettyUsage = ` Usage: hetty [flags] [subcommand] [flags] -Runs an HTTP server with (MITM) proxy, GraphQL service, and a web based admin interface. +Runs an HTTP server with (MITM) proxy and a web based admin interface. Options: --cert Path to root CA certificate. Creates file if it doesn't exist. (Default: "~/.hetty/hetty_cert.pem") @@ -229,14 +228,11 @@ func (cmd *HettyCommand) Exec(ctx context.Context, _ []string) error { req.Method != http.MethodConnect && !strings.HasPrefix(req.RequestURI, "http://") }).Subrouter().StrictSlash(true) - // GraphQL server. - gqlEndpoint := "/api/graphql/" - adminRouter.Path(gqlEndpoint).Handler(api.HTTPHandler(&api.Resolver{ - ProjectService: projService, - RequestLogService: reqLogService, - InterceptService: interceptService, - SenderService: senderService, - }, gqlEndpoint)) + // Connect RPC server. + projPath, projHandler := proj.NewProjectServiceHandler(projService) + adminRouter.PathPrefix(projPath).Handler(projHandler) + reqlogPath, reqlogHandler := reqlog.NewHttpRequestLogServiceHandler(reqLogService) + adminRouter.PathPrefix(reqlogPath).Handler(reqlogHandler) // Admin interface. adminRouter.PathPrefix("").Handler(adminHandler) diff --git a/go.mod b/go.mod index 435b273..a56e6f2 100644 --- a/go.mod +++ b/go.mod @@ -5,44 +5,30 @@ go 1.23 toolchain go1.23.4 require ( - github.com/99designs/gqlgen v0.14.0 + connectrpc.com/connect v1.18.1 github.com/chromedp/chromedp v0.7.8 - github.com/google/go-cmp v0.5.6 + github.com/google/go-cmp v0.5.9 github.com/gorilla/mux v1.7.4 github.com/mitchellh/go-homedir v1.1.0 - github.com/oklog/ulid v1.3.1 + github.com/oklog/ulid/v2 v2.1.0 github.com/peterbourgon/ff/v3 v3.1.2 github.com/smallstep/truststore v0.11.0 - github.com/vektah/gqlparser/v2 v2.2.0 go.etcd.io/bbolt v1.4.0-beta.0 go.uber.org/zap v1.21.0 + google.golang.org/protobuf v1.36.3 ) require ( - github.com/agnivade/levenshtein v1.1.0 // indirect github.com/chromedp/cdproto v0.0.0-20220217222649-d8c14a5c6edf // indirect github.com/chromedp/sysutil v1.0.0 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect github.com/gobwas/httphead v0.1.0 // indirect github.com/gobwas/pool v0.2.1 // indirect github.com/gobwas/ws v1.1.0 // indirect - github.com/gorilla/websocket v1.4.2 // indirect - github.com/hashicorp/golang-lru v0.5.1 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect - github.com/matryer/moq v0.2.5 // indirect - github.com/mitchellh/mapstructure v1.1.2 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/russross/blackfriday/v2 v2.0.1 // indirect - github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect - github.com/urfave/cli/v2 v2.1.1 // indirect - github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e // indirect go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect - golang.org/x/mod v0.4.2 // indirect golang.org/x/sys v0.26.0 // indirect - golang.org/x/tools v0.1.5 // indirect - golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect - gopkg.in/yaml.v2 v2.2.8 // indirect howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect ) diff --git a/go.sum b/go.sum index 9d698cd..1533d66 100644 --- a/go.sum +++ b/go.sum @@ -1,13 +1,6 @@ -github.com/99designs/gqlgen v0.14.0 h1:Wg8aNYQUjMR/4v+W3xD+7SizOy6lSvVeQ06AobNQAXI= -github.com/99designs/gqlgen v0.14.0/go.mod h1:S7z4boV+Nx4VvzMUpVrY/YuHjFX4n7rDyuTqvAkuoRE= +connectrpc.com/connect v1.18.1 h1:PAg7CjSAGvscaf6YZKUefjoih5Z/qYkyaTrBW8xvYPw= +connectrpc.com/connect v1.18.1/go.mod h1:0292hj1rnx8oFrStN7cB4jjVBeqs+Yx5yDIC2prWDO8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= -github.com/agnivade/levenshtein v1.1.0 h1:n6qGwyHG61v3ABce1rPVZklEYRT8NFpCMrpZdBUbYGM= -github.com/agnivade/levenshtein v1.1.0/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= -github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= -github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= -github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q= -github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/chromedp/cdproto v0.0.0-20220217222649-d8c14a5c6edf h1:1omDWNUsWxn2HpiMiMuyRmzjl9uG7RP3IE6GTlpgJWU= @@ -16,61 +9,34 @@ github.com/chromedp/chromedp v0.7.8 h1:JFPIFb28LPjcx6l6mUUzLOTD/TgswcTtg7KrDn8S/ github.com/chromedp/chromedp v0.7.8/go.mod h1:HcIUFBa5vA+u2QI3+xljiU59llUQ8lgGoLzYSCBfmUA= github.com/chromedp/sysutil v1.0.0 h1:+ZxhTpfpZlmchB58ih/LBHX52ky7w2VhQVKQMucy3Ic= github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww= -github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= -github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g= -github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU= github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og= github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/ws v1.1.0 h1:7RFti/xnNkMJnrK7D1yQ/iCIB5OrrY/54/H930kIbHA= github.com/gobwas/ws v1.1.0/go.mod h1:nzvNcVha5eUziGrbxFCo6qFIojQHjJV5cLYIbezhfL0= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= -github.com/gorilla/mux v1.6.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc= github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ= -github.com/matryer/moq v0.2.5 h1:BGQISyhl7Gc9W/gMYmAJONh9mT6AYeyeTjNupNPknMs= -github.com/matryer/moq v0.2.5/go.mod h1:9RtPYjTnH1bSBIkpvtHkFN7nbWAnO7oRpdJkEIn6UtE= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= -github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= -github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU= +github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ= github.com/orisano/pixelmatch v0.0.0-20210112091706-4fa4c7ba91d5 h1:1SoBaSPudixRecmlHXb/GxmaD3fLMtHIDN13QujwQuc= github.com/orisano/pixelmatch v0.0.0-20210112091706-4fa4c7ba91d5/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0= +github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o= github.com/pelletier/go-toml v1.6.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t2kKREewys= github.com/peterbourgon/ff/v3 v3.1.2 h1:0GNhbRhO9yHA4CC27ymskOsuRpmX0YQxwxM9UPiP6JM= github.com/peterbourgon/ff/v3 v3.1.2/go.mod h1:XNJLY8EIl6MjMVjBS4F0+G0LYoAqs0DTa4rmHHukKDE= @@ -79,33 +45,13 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= -github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= -github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= -github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= -github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= github.com/smallstep/truststore v0.11.0 h1:JUTkQ4oHr40jHTS/A2t0usEhteMWG+45CDD2iJA/dIk= github.com/smallstep/truststore v0.11.0/go.mod h1:HwHKRcBi0RUxxw1LYDpTRhYC4jZUuxPpkHdVonlkoDM= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k= -github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= -github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e h1:+w0Zm/9gaWpEAyDlU1eKOuk5twTjAjuevXqcJJw8hrg= -github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U= -github.com/vektah/gqlparser/v2 v2.2.0 h1:bAc3slekAAJW6sZTi07aGq0OrfaCjj4jxARAaC7g2EM= -github.com/vektah/gqlparser/v2 v2.2.0/go.mod h1:i3mQIGIrbK2PD1RrCeMTlVbkF2FJ6WkU1KJlJlC+3F4= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.etcd.io/bbolt v1.4.0-beta.0 h1:U7Y9yH6ZojEo5/BDFMXDXD1RNx9L7iKxudzqR68jLaM= go.etcd.io/bbolt v1.4.0-beta.0/go.mod h1:Qv5yHB6jkQESXT/uVfxJgUPMqgAyhL0GLxcQaz9bSec= @@ -119,32 +65,20 @@ go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201207223542-d4d67f95c62d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -155,27 +89,20 @@ golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200815165600-90abf76919f3/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.36.3 h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU= +google.golang.org/protobuf v1.36.3/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -185,5 +112,3 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= howett.net/plist v0.0.0-20181124034731-591f970eefbb h1:jhnBjNi9UFpfpl8YZhA9CrOqpnJdvzuiHsl/dnxl11M= howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0= -sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= -sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k= diff --git a/gqlgen.yml b/gqlgen.yml deleted file mode 100644 index 85ebbfe..0000000 --- a/gqlgen.yml +++ /dev/null @@ -1,56 +0,0 @@ -# Where are all the schema files located? globs are supported eg src/**/*.graphqls -schema: - - pkg/api/schema.graphql - -# Where should the generated server code go? -exec: - filename: pkg/api/generated.go - package: api - -# Uncomment to enable federation -# federation: -# filename: graph/generated/federation.go -# package: generated - -# Where should any generated models go? -model: - filename: pkg/api/models_gen.go - package: api - -# Where should the resolver implementations go? -resolver: - layout: single-file - filename: pkg/api/resolvers.go - dir: pkg/api - package: api - -# Optional: turn on use `gqlgen:"fieldName"` tags in your models -# struct_tag: json - -# Optional: turn on to use []Thing instead of []*Thing -omit_slice_element_pointers: true -# Optional: set to speed up generation time by not performing a final validation pass. -# skip_validation: true - -# gqlgen will search for any type names in the schema in these go packages -# if they match it will use them, otherwise it will generate them. -# autobind: -# - "github.com/dstotijn/hetty/graph/model" - -# This section declares type mapping between the GraphQL and go type systems -# -# The first line in each type will be used as defaults for resolver arguments and -# modelgen, the others will be allowed when binding to fields. Configure them to -# your liking -models: - ID: - model: - - github.com/dstotijn/hetty/pkg/api.ULID - URL: - model: - - github.com/dstotijn/hetty/pkg/api.URL -# Int: -# model: -# - github.com/99designs/gqlgen/graphql.Int -# - github.com/99designs/gqlgen/graphql.Int64 -# - github.com/99designs/gqlgen/graphql.Int32 diff --git a/pkg/api/generated.go b/pkg/api/generated.go deleted file mode 100644 index 5a064e3..0000000 --- a/pkg/api/generated.go +++ /dev/null @@ -1,8995 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package api - -import ( - "bytes" - "context" - "errors" - "net/url" - "strconv" - "sync" - "sync/atomic" - "time" - - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/introspection" - "github.com/oklog/ulid" - gqlparser "github.com/vektah/gqlparser/v2" - "github.com/vektah/gqlparser/v2/ast" -) - -// region ************************** generated!.gotpl ************************** - -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} - -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} - -type ResolverRoot interface { - Mutation() MutationResolver - Query() QueryResolver -} - -type DirectiveRoot struct { -} - -type ComplexityRoot struct { - CancelRequestResult struct { - Success func(childComplexity int) int - } - - CancelResponseResult struct { - Success func(childComplexity int) int - } - - ClearHTTPRequestLogResult struct { - Success func(childComplexity int) int - } - - CloseProjectResult struct { - Success func(childComplexity int) int - } - - DeleteProjectResult struct { - Success func(childComplexity int) int - } - - DeleteSenderRequestsResult struct { - Success func(childComplexity int) int - } - - HTTPHeader struct { - Key func(childComplexity int) int - Value func(childComplexity int) int - } - - HTTPRequest struct { - Body func(childComplexity int) int - Headers func(childComplexity int) int - ID func(childComplexity int) int - Method func(childComplexity int) int - Proto func(childComplexity int) int - Response func(childComplexity int) int - URL func(childComplexity int) int - } - - HTTPRequestLog struct { - Body func(childComplexity int) int - Headers func(childComplexity int) int - ID func(childComplexity int) int - Method func(childComplexity int) int - Proto func(childComplexity int) int - Response func(childComplexity int) int - Timestamp func(childComplexity int) int - URL func(childComplexity int) int - } - - HTTPRequestLogFilter struct { - OnlyInScope func(childComplexity int) int - SearchExpression func(childComplexity int) int - } - - HTTPResponse struct { - Body func(childComplexity int) int - Headers func(childComplexity int) int - ID func(childComplexity int) int - Proto func(childComplexity int) int - StatusCode func(childComplexity int) int - StatusReason func(childComplexity int) int - } - - HTTPResponseLog struct { - Body func(childComplexity int) int - Headers func(childComplexity int) int - ID func(childComplexity int) int - Proto func(childComplexity int) int - StatusCode func(childComplexity int) int - StatusReason func(childComplexity int) int - } - - InterceptSettings struct { - RequestFilter func(childComplexity int) int - RequestsEnabled func(childComplexity int) int - ResponseFilter func(childComplexity int) int - ResponsesEnabled func(childComplexity int) int - } - - ModifyRequestResult struct { - Success func(childComplexity int) int - } - - ModifyResponseResult struct { - Success func(childComplexity int) int - } - - Mutation struct { - CancelRequest func(childComplexity int, id ulid.ULID) int - CancelResponse func(childComplexity int, requestID ulid.ULID) int - ClearHTTPRequestLog func(childComplexity int) int - CloseProject func(childComplexity int) int - CreateOrUpdateSenderRequest func(childComplexity int, request SenderRequestInput) int - CreateProject func(childComplexity int, name string) int - CreateSenderRequestFromHTTPRequestLog func(childComplexity int, id ulid.ULID) int - DeleteProject func(childComplexity int, id ulid.ULID) int - DeleteSenderRequests func(childComplexity int) int - ModifyRequest func(childComplexity int, request ModifyRequestInput) int - ModifyResponse func(childComplexity int, response ModifyResponseInput) int - OpenProject func(childComplexity int, id ulid.ULID) int - SendRequest func(childComplexity int, id ulid.ULID) int - SetHTTPRequestLogFilter func(childComplexity int, filter *HTTPRequestLogFilterInput) int - SetScope func(childComplexity int, scope []ScopeRuleInput) int - SetSenderRequestFilter func(childComplexity int, filter *SenderRequestFilterInput) int - UpdateInterceptSettings func(childComplexity int, input UpdateInterceptSettingsInput) int - } - - Project struct { - ID func(childComplexity int) int - IsActive func(childComplexity int) int - Name func(childComplexity int) int - Settings func(childComplexity int) int - } - - ProjectSettings struct { - Intercept func(childComplexity int) int - } - - Query struct { - ActiveProject func(childComplexity int) int - HTTPRequestLog func(childComplexity int, id ulid.ULID) int - HTTPRequestLogFilter func(childComplexity int) int - HTTPRequestLogs func(childComplexity int) int - InterceptedRequest func(childComplexity int, id ulid.ULID) int - InterceptedRequests func(childComplexity int) int - Projects func(childComplexity int) int - Scope func(childComplexity int) int - SenderRequest func(childComplexity int, id ulid.ULID) int - SenderRequests func(childComplexity int) int - } - - ScopeHeader struct { - Key func(childComplexity int) int - Value func(childComplexity int) int - } - - ScopeRule struct { - Body func(childComplexity int) int - Header func(childComplexity int) int - URL func(childComplexity int) int - } - - SenderRequest struct { - Body func(childComplexity int) int - Headers func(childComplexity int) int - ID func(childComplexity int) int - Method func(childComplexity int) int - Proto func(childComplexity int) int - Response func(childComplexity int) int - SourceRequestLogID func(childComplexity int) int - Timestamp func(childComplexity int) int - URL func(childComplexity int) int - } - - SenderRequestFilter struct { - OnlyInScope func(childComplexity int) int - SearchExpression func(childComplexity int) int - } -} - -type MutationResolver interface { - CreateProject(ctx context.Context, name string) (*Project, error) - OpenProject(ctx context.Context, id ulid.ULID) (*Project, error) - CloseProject(ctx context.Context) (*CloseProjectResult, error) - DeleteProject(ctx context.Context, id ulid.ULID) (*DeleteProjectResult, error) - ClearHTTPRequestLog(ctx context.Context) (*ClearHTTPRequestLogResult, error) - SetScope(ctx context.Context, scope []ScopeRuleInput) ([]ScopeRule, error) - SetHTTPRequestLogFilter(ctx context.Context, filter *HTTPRequestLogFilterInput) (*HTTPRequestLogFilter, error) - SetSenderRequestFilter(ctx context.Context, filter *SenderRequestFilterInput) (*SenderRequestFilter, error) - CreateOrUpdateSenderRequest(ctx context.Context, request SenderRequestInput) (*SenderRequest, error) - CreateSenderRequestFromHTTPRequestLog(ctx context.Context, id ulid.ULID) (*SenderRequest, error) - SendRequest(ctx context.Context, id ulid.ULID) (*SenderRequest, error) - DeleteSenderRequests(ctx context.Context) (*DeleteSenderRequestsResult, error) - ModifyRequest(ctx context.Context, request ModifyRequestInput) (*ModifyRequestResult, error) - CancelRequest(ctx context.Context, id ulid.ULID) (*CancelRequestResult, error) - ModifyResponse(ctx context.Context, response ModifyResponseInput) (*ModifyResponseResult, error) - CancelResponse(ctx context.Context, requestID ulid.ULID) (*CancelResponseResult, error) - UpdateInterceptSettings(ctx context.Context, input UpdateInterceptSettingsInput) (*InterceptSettings, error) -} -type QueryResolver interface { - HTTPRequestLog(ctx context.Context, id ulid.ULID) (*HTTPRequestLog, error) - HTTPRequestLogs(ctx context.Context) ([]HTTPRequestLog, error) - HTTPRequestLogFilter(ctx context.Context) (*HTTPRequestLogFilter, error) - ActiveProject(ctx context.Context) (*Project, error) - Projects(ctx context.Context) ([]Project, error) - Scope(ctx context.Context) ([]ScopeRule, error) - SenderRequest(ctx context.Context, id ulid.ULID) (*SenderRequest, error) - SenderRequests(ctx context.Context) ([]SenderRequest, error) - InterceptedRequests(ctx context.Context) ([]HTTPRequest, error) - InterceptedRequest(ctx context.Context, id ulid.ULID) (*HTTPRequest, error) -} - -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} - -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema -} - -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - ec := executionContext{nil, e} - _ = ec - switch typeName + "." + field { - - case "CancelRequestResult.success": - if e.complexity.CancelRequestResult.Success == nil { - break - } - - return e.complexity.CancelRequestResult.Success(childComplexity), true - - case "CancelResponseResult.success": - if e.complexity.CancelResponseResult.Success == nil { - break - } - - return e.complexity.CancelResponseResult.Success(childComplexity), true - - case "ClearHTTPRequestLogResult.success": - if e.complexity.ClearHTTPRequestLogResult.Success == nil { - break - } - - return e.complexity.ClearHTTPRequestLogResult.Success(childComplexity), true - - case "CloseProjectResult.success": - if e.complexity.CloseProjectResult.Success == nil { - break - } - - return e.complexity.CloseProjectResult.Success(childComplexity), true - - case "DeleteProjectResult.success": - if e.complexity.DeleteProjectResult.Success == nil { - break - } - - return e.complexity.DeleteProjectResult.Success(childComplexity), true - - case "DeleteSenderRequestsResult.success": - if e.complexity.DeleteSenderRequestsResult.Success == nil { - break - } - - return e.complexity.DeleteSenderRequestsResult.Success(childComplexity), true - - case "HttpHeader.key": - if e.complexity.HTTPHeader.Key == nil { - break - } - - return e.complexity.HTTPHeader.Key(childComplexity), true - - case "HttpHeader.value": - if e.complexity.HTTPHeader.Value == nil { - break - } - - return e.complexity.HTTPHeader.Value(childComplexity), true - - case "HttpRequest.body": - if e.complexity.HTTPRequest.Body == nil { - break - } - - return e.complexity.HTTPRequest.Body(childComplexity), true - - case "HttpRequest.headers": - if e.complexity.HTTPRequest.Headers == nil { - break - } - - return e.complexity.HTTPRequest.Headers(childComplexity), true - - case "HttpRequest.id": - if e.complexity.HTTPRequest.ID == nil { - break - } - - return e.complexity.HTTPRequest.ID(childComplexity), true - - case "HttpRequest.method": - if e.complexity.HTTPRequest.Method == nil { - break - } - - return e.complexity.HTTPRequest.Method(childComplexity), true - - case "HttpRequest.proto": - if e.complexity.HTTPRequest.Proto == nil { - break - } - - return e.complexity.HTTPRequest.Proto(childComplexity), true - - case "HttpRequest.response": - if e.complexity.HTTPRequest.Response == nil { - break - } - - return e.complexity.HTTPRequest.Response(childComplexity), true - - case "HttpRequest.url": - if e.complexity.HTTPRequest.URL == nil { - break - } - - return e.complexity.HTTPRequest.URL(childComplexity), true - - case "HttpRequestLog.body": - if e.complexity.HTTPRequestLog.Body == nil { - break - } - - return e.complexity.HTTPRequestLog.Body(childComplexity), true - - case "HttpRequestLog.headers": - if e.complexity.HTTPRequestLog.Headers == nil { - break - } - - return e.complexity.HTTPRequestLog.Headers(childComplexity), true - - case "HttpRequestLog.id": - if e.complexity.HTTPRequestLog.ID == nil { - break - } - - return e.complexity.HTTPRequestLog.ID(childComplexity), true - - case "HttpRequestLog.method": - if e.complexity.HTTPRequestLog.Method == nil { - break - } - - return e.complexity.HTTPRequestLog.Method(childComplexity), true - - case "HttpRequestLog.proto": - if e.complexity.HTTPRequestLog.Proto == nil { - break - } - - return e.complexity.HTTPRequestLog.Proto(childComplexity), true - - case "HttpRequestLog.response": - if e.complexity.HTTPRequestLog.Response == nil { - break - } - - return e.complexity.HTTPRequestLog.Response(childComplexity), true - - case "HttpRequestLog.timestamp": - if e.complexity.HTTPRequestLog.Timestamp == nil { - break - } - - return e.complexity.HTTPRequestLog.Timestamp(childComplexity), true - - case "HttpRequestLog.url": - if e.complexity.HTTPRequestLog.URL == nil { - break - } - - return e.complexity.HTTPRequestLog.URL(childComplexity), true - - case "HttpRequestLogFilter.onlyInScope": - if e.complexity.HTTPRequestLogFilter.OnlyInScope == nil { - break - } - - return e.complexity.HTTPRequestLogFilter.OnlyInScope(childComplexity), true - - case "HttpRequestLogFilter.searchExpression": - if e.complexity.HTTPRequestLogFilter.SearchExpression == nil { - break - } - - return e.complexity.HTTPRequestLogFilter.SearchExpression(childComplexity), true - - case "HttpResponse.body": - if e.complexity.HTTPResponse.Body == nil { - break - } - - return e.complexity.HTTPResponse.Body(childComplexity), true - - case "HttpResponse.headers": - if e.complexity.HTTPResponse.Headers == nil { - break - } - - return e.complexity.HTTPResponse.Headers(childComplexity), true - - case "HttpResponse.id": - if e.complexity.HTTPResponse.ID == nil { - break - } - - return e.complexity.HTTPResponse.ID(childComplexity), true - - case "HttpResponse.proto": - if e.complexity.HTTPResponse.Proto == nil { - break - } - - return e.complexity.HTTPResponse.Proto(childComplexity), true - - case "HttpResponse.statusCode": - if e.complexity.HTTPResponse.StatusCode == nil { - break - } - - return e.complexity.HTTPResponse.StatusCode(childComplexity), true - - case "HttpResponse.statusReason": - if e.complexity.HTTPResponse.StatusReason == nil { - break - } - - return e.complexity.HTTPResponse.StatusReason(childComplexity), true - - case "HttpResponseLog.body": - if e.complexity.HTTPResponseLog.Body == nil { - break - } - - return e.complexity.HTTPResponseLog.Body(childComplexity), true - - case "HttpResponseLog.headers": - if e.complexity.HTTPResponseLog.Headers == nil { - break - } - - return e.complexity.HTTPResponseLog.Headers(childComplexity), true - - case "HttpResponseLog.id": - if e.complexity.HTTPResponseLog.ID == nil { - break - } - - return e.complexity.HTTPResponseLog.ID(childComplexity), true - - case "HttpResponseLog.proto": - if e.complexity.HTTPResponseLog.Proto == nil { - break - } - - return e.complexity.HTTPResponseLog.Proto(childComplexity), true - - case "HttpResponseLog.statusCode": - if e.complexity.HTTPResponseLog.StatusCode == nil { - break - } - - return e.complexity.HTTPResponseLog.StatusCode(childComplexity), true - - case "HttpResponseLog.statusReason": - if e.complexity.HTTPResponseLog.StatusReason == nil { - break - } - - return e.complexity.HTTPResponseLog.StatusReason(childComplexity), true - - case "InterceptSettings.requestFilter": - if e.complexity.InterceptSettings.RequestFilter == nil { - break - } - - return e.complexity.InterceptSettings.RequestFilter(childComplexity), true - - case "InterceptSettings.requestsEnabled": - if e.complexity.InterceptSettings.RequestsEnabled == nil { - break - } - - return e.complexity.InterceptSettings.RequestsEnabled(childComplexity), true - - case "InterceptSettings.responseFilter": - if e.complexity.InterceptSettings.ResponseFilter == nil { - break - } - - return e.complexity.InterceptSettings.ResponseFilter(childComplexity), true - - case "InterceptSettings.responsesEnabled": - if e.complexity.InterceptSettings.ResponsesEnabled == nil { - break - } - - return e.complexity.InterceptSettings.ResponsesEnabled(childComplexity), true - - case "ModifyRequestResult.success": - if e.complexity.ModifyRequestResult.Success == nil { - break - } - - return e.complexity.ModifyRequestResult.Success(childComplexity), true - - case "ModifyResponseResult.success": - if e.complexity.ModifyResponseResult.Success == nil { - break - } - - return e.complexity.ModifyResponseResult.Success(childComplexity), true - - case "Mutation.cancelRequest": - if e.complexity.Mutation.CancelRequest == nil { - break - } - - args, err := ec.field_Mutation_cancelRequest_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.CancelRequest(childComplexity, args["id"].(ulid.ULID)), true - - case "Mutation.cancelResponse": - if e.complexity.Mutation.CancelResponse == nil { - break - } - - args, err := ec.field_Mutation_cancelResponse_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.CancelResponse(childComplexity, args["requestID"].(ulid.ULID)), true - - case "Mutation.clearHTTPRequestLog": - if e.complexity.Mutation.ClearHTTPRequestLog == nil { - break - } - - return e.complexity.Mutation.ClearHTTPRequestLog(childComplexity), true - - case "Mutation.closeProject": - if e.complexity.Mutation.CloseProject == nil { - break - } - - return e.complexity.Mutation.CloseProject(childComplexity), true - - case "Mutation.createOrUpdateSenderRequest": - if e.complexity.Mutation.CreateOrUpdateSenderRequest == nil { - break - } - - args, err := ec.field_Mutation_createOrUpdateSenderRequest_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.CreateOrUpdateSenderRequest(childComplexity, args["request"].(SenderRequestInput)), true - - case "Mutation.createProject": - if e.complexity.Mutation.CreateProject == nil { - break - } - - args, err := ec.field_Mutation_createProject_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.CreateProject(childComplexity, args["name"].(string)), true - - case "Mutation.createSenderRequestFromHttpRequestLog": - if e.complexity.Mutation.CreateSenderRequestFromHTTPRequestLog == nil { - break - } - - args, err := ec.field_Mutation_createSenderRequestFromHttpRequestLog_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.CreateSenderRequestFromHTTPRequestLog(childComplexity, args["id"].(ulid.ULID)), true - - case "Mutation.deleteProject": - if e.complexity.Mutation.DeleteProject == nil { - break - } - - args, err := ec.field_Mutation_deleteProject_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.DeleteProject(childComplexity, args["id"].(ulid.ULID)), true - - case "Mutation.deleteSenderRequests": - if e.complexity.Mutation.DeleteSenderRequests == nil { - break - } - - return e.complexity.Mutation.DeleteSenderRequests(childComplexity), true - - case "Mutation.modifyRequest": - if e.complexity.Mutation.ModifyRequest == nil { - break - } - - args, err := ec.field_Mutation_modifyRequest_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.ModifyRequest(childComplexity, args["request"].(ModifyRequestInput)), true - - case "Mutation.modifyResponse": - if e.complexity.Mutation.ModifyResponse == nil { - break - } - - args, err := ec.field_Mutation_modifyResponse_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.ModifyResponse(childComplexity, args["response"].(ModifyResponseInput)), true - - case "Mutation.openProject": - if e.complexity.Mutation.OpenProject == nil { - break - } - - args, err := ec.field_Mutation_openProject_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.OpenProject(childComplexity, args["id"].(ulid.ULID)), true - - case "Mutation.sendRequest": - if e.complexity.Mutation.SendRequest == nil { - break - } - - args, err := ec.field_Mutation_sendRequest_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.SendRequest(childComplexity, args["id"].(ulid.ULID)), true - - case "Mutation.setHttpRequestLogFilter": - if e.complexity.Mutation.SetHTTPRequestLogFilter == nil { - break - } - - args, err := ec.field_Mutation_setHttpRequestLogFilter_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.SetHTTPRequestLogFilter(childComplexity, args["filter"].(*HTTPRequestLogFilterInput)), true - - case "Mutation.setScope": - if e.complexity.Mutation.SetScope == nil { - break - } - - args, err := ec.field_Mutation_setScope_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.SetScope(childComplexity, args["scope"].([]ScopeRuleInput)), true - - case "Mutation.setSenderRequestFilter": - if e.complexity.Mutation.SetSenderRequestFilter == nil { - break - } - - args, err := ec.field_Mutation_setSenderRequestFilter_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.SetSenderRequestFilter(childComplexity, args["filter"].(*SenderRequestFilterInput)), true - - case "Mutation.updateInterceptSettings": - if e.complexity.Mutation.UpdateInterceptSettings == nil { - break - } - - args, err := ec.field_Mutation_updateInterceptSettings_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.UpdateInterceptSettings(childComplexity, args["input"].(UpdateInterceptSettingsInput)), true - - case "Project.id": - if e.complexity.Project.ID == nil { - break - } - - return e.complexity.Project.ID(childComplexity), true - - case "Project.isActive": - if e.complexity.Project.IsActive == nil { - break - } - - return e.complexity.Project.IsActive(childComplexity), true - - case "Project.name": - if e.complexity.Project.Name == nil { - break - } - - return e.complexity.Project.Name(childComplexity), true - - case "Project.settings": - if e.complexity.Project.Settings == nil { - break - } - - return e.complexity.Project.Settings(childComplexity), true - - case "ProjectSettings.intercept": - if e.complexity.ProjectSettings.Intercept == nil { - break - } - - return e.complexity.ProjectSettings.Intercept(childComplexity), true - - case "Query.activeProject": - if e.complexity.Query.ActiveProject == nil { - break - } - - return e.complexity.Query.ActiveProject(childComplexity), true - - case "Query.httpRequestLog": - if e.complexity.Query.HTTPRequestLog == nil { - break - } - - args, err := ec.field_Query_httpRequestLog_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.HTTPRequestLog(childComplexity, args["id"].(ulid.ULID)), true - - case "Query.httpRequestLogFilter": - if e.complexity.Query.HTTPRequestLogFilter == nil { - break - } - - return e.complexity.Query.HTTPRequestLogFilter(childComplexity), true - - case "Query.httpRequestLogs": - if e.complexity.Query.HTTPRequestLogs == nil { - break - } - - return e.complexity.Query.HTTPRequestLogs(childComplexity), true - - case "Query.interceptedRequest": - if e.complexity.Query.InterceptedRequest == nil { - break - } - - args, err := ec.field_Query_interceptedRequest_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.InterceptedRequest(childComplexity, args["id"].(ulid.ULID)), true - - case "Query.interceptedRequests": - if e.complexity.Query.InterceptedRequests == nil { - break - } - - return e.complexity.Query.InterceptedRequests(childComplexity), true - - case "Query.projects": - if e.complexity.Query.Projects == nil { - break - } - - return e.complexity.Query.Projects(childComplexity), true - - case "Query.scope": - if e.complexity.Query.Scope == nil { - break - } - - return e.complexity.Query.Scope(childComplexity), true - - case "Query.senderRequest": - if e.complexity.Query.SenderRequest == nil { - break - } - - args, err := ec.field_Query_senderRequest_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.SenderRequest(childComplexity, args["id"].(ulid.ULID)), true - - case "Query.senderRequests": - if e.complexity.Query.SenderRequests == nil { - break - } - - return e.complexity.Query.SenderRequests(childComplexity), true - - case "ScopeHeader.key": - if e.complexity.ScopeHeader.Key == nil { - break - } - - return e.complexity.ScopeHeader.Key(childComplexity), true - - case "ScopeHeader.value": - if e.complexity.ScopeHeader.Value == nil { - break - } - - return e.complexity.ScopeHeader.Value(childComplexity), true - - case "ScopeRule.body": - if e.complexity.ScopeRule.Body == nil { - break - } - - return e.complexity.ScopeRule.Body(childComplexity), true - - case "ScopeRule.header": - if e.complexity.ScopeRule.Header == nil { - break - } - - return e.complexity.ScopeRule.Header(childComplexity), true - - case "ScopeRule.url": - if e.complexity.ScopeRule.URL == nil { - break - } - - return e.complexity.ScopeRule.URL(childComplexity), true - - case "SenderRequest.body": - if e.complexity.SenderRequest.Body == nil { - break - } - - return e.complexity.SenderRequest.Body(childComplexity), true - - case "SenderRequest.headers": - if e.complexity.SenderRequest.Headers == nil { - break - } - - return e.complexity.SenderRequest.Headers(childComplexity), true - - case "SenderRequest.id": - if e.complexity.SenderRequest.ID == nil { - break - } - - return e.complexity.SenderRequest.ID(childComplexity), true - - case "SenderRequest.method": - if e.complexity.SenderRequest.Method == nil { - break - } - - return e.complexity.SenderRequest.Method(childComplexity), true - - case "SenderRequest.proto": - if e.complexity.SenderRequest.Proto == nil { - break - } - - return e.complexity.SenderRequest.Proto(childComplexity), true - - case "SenderRequest.response": - if e.complexity.SenderRequest.Response == nil { - break - } - - return e.complexity.SenderRequest.Response(childComplexity), true - - case "SenderRequest.sourceRequestLogID": - if e.complexity.SenderRequest.SourceRequestLogID == nil { - break - } - - return e.complexity.SenderRequest.SourceRequestLogID(childComplexity), true - - case "SenderRequest.timestamp": - if e.complexity.SenderRequest.Timestamp == nil { - break - } - - return e.complexity.SenderRequest.Timestamp(childComplexity), true - - case "SenderRequest.url": - if e.complexity.SenderRequest.URL == nil { - break - } - - return e.complexity.SenderRequest.URL(childComplexity), true - - case "SenderRequestFilter.onlyInScope": - if e.complexity.SenderRequestFilter.OnlyInScope == nil { - break - } - - return e.complexity.SenderRequestFilter.OnlyInScope(childComplexity), true - - case "SenderRequestFilter.searchExpression": - if e.complexity.SenderRequestFilter.SearchExpression == nil { - break - } - - return e.complexity.SenderRequestFilter.SearchExpression(childComplexity), true - - } - return 0, false -} - -func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { - rc := graphql.GetOperationContext(ctx) - ec := executionContext{rc, e} - first := true - - switch rc.Operation.Operation { - case ast.Query: - return func(ctx context.Context) *graphql.Response { - if !first { - return nil - } - first = false - data := ec._Query(ctx, rc.Operation.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - - return &graphql.Response{ - Data: buf.Bytes(), - } - } - case ast.Mutation: - return func(ctx context.Context) *graphql.Response { - if !first { - return nil - } - first = false - data := ec._Mutation(ctx, rc.Operation.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - - return &graphql.Response{ - Data: buf.Bytes(), - } - } - - default: - return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) - } -} - -type executionContext struct { - *graphql.OperationContext - *executableSchema -} - -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") - } - return introspection.WrapSchema(parsedSchema), nil -} - -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") - } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil -} - -var sources = []*ast.Source{ - {Name: "pkg/api/schema.graphql", Input: `type HttpRequestLog { - id: ID! - url: String! - method: HttpMethod! - proto: String! - headers: [HttpHeader!]! - body: String - timestamp: Time! - response: HttpResponseLog -} - -type HttpResponseLog { - """ - Will be the same ID as its related request ID. - """ - id: ID! - proto: HttpProtocol! - statusCode: Int! - statusReason: String! - body: String - headers: [HttpHeader!]! -} - -type HttpHeader { - key: String! - value: String! -} - -type Project { - id: ID! - name: String! - isActive: Boolean! - settings: ProjectSettings! -} - -type ProjectSettings { - intercept: InterceptSettings! -} - -type ScopeRule { - url: Regexp - header: ScopeHeader - body: Regexp -} - -input ScopeRuleInput { - url: Regexp - header: ScopeHeaderInput - body: Regexp -} - -type ScopeHeader { - key: Regexp - value: Regexp -} - -input ScopeHeaderInput { - key: Regexp - value: Regexp -} - -type CloseProjectResult { - success: Boolean! -} - -type DeleteProjectResult { - success: Boolean! -} - -type ClearHTTPRequestLogResult { - success: Boolean! -} - -type DeleteSenderRequestsResult { - success: Boolean! -} - -input HttpRequestLogFilterInput { - onlyInScope: Boolean - searchExpression: String -} - -type HttpRequestLogFilter { - onlyInScope: Boolean! - searchExpression: String -} - -input SenderRequestInput { - id: ID - url: URL! - method: HttpMethod - proto: HttpProtocol - headers: [HttpHeaderInput!] - body: String -} - -input HttpHeaderInput { - key: String! - value: String! -} - -type SenderRequest { - id: ID! - sourceRequestLogID: ID - url: URL! - method: HttpMethod! - proto: HttpProtocol! - headers: [HttpHeader!] - body: String - timestamp: Time! - response: HttpResponseLog -} - -input SenderRequestFilterInput { - onlyInScope: Boolean - searchExpression: String -} - -type SenderRequestFilter { - onlyInScope: Boolean! - searchExpression: String -} - -type HttpRequest { - id: ID! - url: URL! - method: HttpMethod! - proto: HttpProtocol! - headers: [HttpHeader!]! - body: String - response: HttpResponse -} - -type HttpResponse { - """ - Will be the same ID as its related request ID. - """ - id: ID! - proto: HttpProtocol! - statusCode: Int! - statusReason: String! - body: String - headers: [HttpHeader!]! -} - -input ModifyRequestInput { - id: ID! - url: URL! - method: HttpMethod! - proto: HttpProtocol! - headers: [HttpHeaderInput!] - body: String - modifyResponse: Boolean -} - -type ModifyRequestResult { - success: Boolean! -} - -type CancelRequestResult { - success: Boolean! -} - -input ModifyResponseInput { - requestID: ID! - proto: HttpProtocol! - headers: [HttpHeaderInput!] - body: String - statusCode: Int! - statusReason: String! -} - -type ModifyResponseResult { - success: Boolean! -} - -type CancelResponseResult { - success: Boolean! -} - -input UpdateInterceptSettingsInput { - requestsEnabled: Boolean! - responsesEnabled: Boolean! - requestFilter: String - responseFilter: String -} - -type InterceptSettings { - requestsEnabled: Boolean! - responsesEnabled: Boolean! - requestFilter: String - responseFilter: String -} - -type Query { - httpRequestLog(id: ID!): HttpRequestLog - httpRequestLogs: [HttpRequestLog!]! - httpRequestLogFilter: HttpRequestLogFilter - activeProject: Project - projects: [Project!]! - scope: [ScopeRule!]! - senderRequest(id: ID!): SenderRequest - senderRequests: [SenderRequest!]! - interceptedRequests: [HttpRequest!]! - interceptedRequest(id: ID!): HttpRequest -} - -type Mutation { - createProject(name: String!): Project - openProject(id: ID!): Project - closeProject: CloseProjectResult! - deleteProject(id: ID!): DeleteProjectResult! - clearHTTPRequestLog: ClearHTTPRequestLogResult! - setScope(scope: [ScopeRuleInput!]!): [ScopeRule!]! - setHttpRequestLogFilter( - filter: HttpRequestLogFilterInput - ): HttpRequestLogFilter - setSenderRequestFilter(filter: SenderRequestFilterInput): SenderRequestFilter - createOrUpdateSenderRequest(request: SenderRequestInput!): SenderRequest! - createSenderRequestFromHttpRequestLog(id: ID!): SenderRequest! - sendRequest(id: ID!): SenderRequest! - deleteSenderRequests: DeleteSenderRequestsResult! - modifyRequest(request: ModifyRequestInput!): ModifyRequestResult! - cancelRequest(id: ID!): CancelRequestResult! - modifyResponse(response: ModifyResponseInput!): ModifyResponseResult! - cancelResponse(requestID: ID!): CancelResponseResult! - updateInterceptSettings( - input: UpdateInterceptSettingsInput! - ): InterceptSettings! -} - -enum HttpMethod { - GET - HEAD - POST - PUT - DELETE - CONNECT - OPTIONS - TRACE - PATCH -} - -enum HttpProtocol { - HTTP10 - HTTP11 - HTTP20 -} - -scalar Time -scalar Regexp -scalar URL -`, BuiltIn: false}, -} -var parsedSchema = gqlparser.MustLoadSchema(sources...) - -// endregion ************************** generated!.gotpl ************************** - -// region ***************************** args.gotpl ***************************** - -func (ec *executionContext) field_Mutation_cancelRequest_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 ulid.ULID - if tmp, ok := rawArgs["id"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - arg0, err = ec.unmarshalNID2githubᚗcomᚋoklogᚋulidᚐULID(ctx, tmp) - if err != nil { - return nil, err - } - } - args["id"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_cancelResponse_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 ulid.ULID - if tmp, ok := rawArgs["requestID"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("requestID")) - arg0, err = ec.unmarshalNID2githubᚗcomᚋoklogᚋulidᚐULID(ctx, tmp) - if err != nil { - return nil, err - } - } - args["requestID"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_createOrUpdateSenderRequest_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 SenderRequestInput - if tmp, ok := rawArgs["request"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("request")) - arg0, err = ec.unmarshalNSenderRequestInput2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐSenderRequestInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["request"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_createProject_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["name"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_createSenderRequestFromHttpRequestLog_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 ulid.ULID - if tmp, ok := rawArgs["id"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - arg0, err = ec.unmarshalNID2githubᚗcomᚋoklogᚋulidᚐULID(ctx, tmp) - if err != nil { - return nil, err - } - } - args["id"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_deleteProject_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 ulid.ULID - if tmp, ok := rawArgs["id"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - arg0, err = ec.unmarshalNID2githubᚗcomᚋoklogᚋulidᚐULID(ctx, tmp) - if err != nil { - return nil, err - } - } - args["id"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_modifyRequest_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 ModifyRequestInput - if tmp, ok := rawArgs["request"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("request")) - arg0, err = ec.unmarshalNModifyRequestInput2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐModifyRequestInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["request"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_modifyResponse_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 ModifyResponseInput - if tmp, ok := rawArgs["response"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("response")) - arg0, err = ec.unmarshalNModifyResponseInput2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐModifyResponseInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["response"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_openProject_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 ulid.ULID - if tmp, ok := rawArgs["id"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - arg0, err = ec.unmarshalNID2githubᚗcomᚋoklogᚋulidᚐULID(ctx, tmp) - if err != nil { - return nil, err - } - } - args["id"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_sendRequest_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 ulid.ULID - if tmp, ok := rawArgs["id"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - arg0, err = ec.unmarshalNID2githubᚗcomᚋoklogᚋulidᚐULID(ctx, tmp) - if err != nil { - return nil, err - } - } - args["id"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_setHttpRequestLogFilter_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 *HTTPRequestLogFilterInput - if tmp, ok := rawArgs["filter"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) - arg0, err = ec.unmarshalOHttpRequestLogFilterInput2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPRequestLogFilterInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["filter"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_setScope_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 []ScopeRuleInput - if tmp, ok := rawArgs["scope"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("scope")) - arg0, err = ec.unmarshalNScopeRuleInput2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐScopeRuleInputᚄ(ctx, tmp) - if err != nil { - return nil, err - } - } - args["scope"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_setSenderRequestFilter_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 *SenderRequestFilterInput - if tmp, ok := rawArgs["filter"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("filter")) - arg0, err = ec.unmarshalOSenderRequestFilterInput2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐSenderRequestFilterInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["filter"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_updateInterceptSettings_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 UpdateInterceptSettingsInput - if tmp, ok := rawArgs["input"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) - arg0, err = ec.unmarshalNUpdateInterceptSettingsInput2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐUpdateInterceptSettingsInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["input"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["name"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query_httpRequestLog_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 ulid.ULID - if tmp, ok := rawArgs["id"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - arg0, err = ec.unmarshalNID2githubᚗcomᚋoklogᚋulidᚐULID(ctx, tmp) - if err != nil { - return nil, err - } - } - args["id"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query_interceptedRequest_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 ulid.ULID - if tmp, ok := rawArgs["id"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - arg0, err = ec.unmarshalNID2githubᚗcomᚋoklogᚋulidᚐULID(ctx, tmp) - if err != nil { - return nil, err - } - } - args["id"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query_senderRequest_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 ulid.ULID - if tmp, ok := rawArgs["id"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - arg0, err = ec.unmarshalNID2githubᚗcomᚋoklogᚋulidᚐULID(ctx, tmp) - if err != nil { - return nil, err - } - } - args["id"] = arg0 - return args, nil -} - -func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) - arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil -} - -func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) - arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil -} - -// endregion ***************************** args.gotpl ***************************** - -// region ************************** directives.gotpl ************************** - -// endregion ************************** directives.gotpl ************************** - -// region **************************** field.gotpl ***************************** - -func (ec *executionContext) _CancelRequestResult_success(ctx context.Context, field graphql.CollectedField, obj *CancelRequestResult) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "CancelRequestResult", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Success, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _CancelResponseResult_success(ctx context.Context, field graphql.CollectedField, obj *CancelResponseResult) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "CancelResponseResult", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Success, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _ClearHTTPRequestLogResult_success(ctx context.Context, field graphql.CollectedField, obj *ClearHTTPRequestLogResult) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "ClearHTTPRequestLogResult", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Success, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _CloseProjectResult_success(ctx context.Context, field graphql.CollectedField, obj *CloseProjectResult) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "CloseProjectResult", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Success, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _DeleteProjectResult_success(ctx context.Context, field graphql.CollectedField, obj *DeleteProjectResult) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "DeleteProjectResult", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Success, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _DeleteSenderRequestsResult_success(ctx context.Context, field graphql.CollectedField, obj *DeleteSenderRequestsResult) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "DeleteSenderRequestsResult", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Success, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpHeader_key(ctx context.Context, field graphql.CollectedField, obj *HTTPHeader) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpHeader", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Key, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpHeader_value(ctx context.Context, field graphql.CollectedField, obj *HTTPHeader) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpHeader", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Value, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpRequest_id(ctx context.Context, field graphql.CollectedField, obj *HTTPRequest) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpRequest", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(ulid.ULID) - fc.Result = res - return ec.marshalNID2githubᚗcomᚋoklogᚋulidᚐULID(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpRequest_url(ctx context.Context, field graphql.CollectedField, obj *HTTPRequest) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpRequest", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.URL, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*url.URL) - fc.Result = res - return ec.marshalNURL2ᚖnetᚋurlᚐURL(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpRequest_method(ctx context.Context, field graphql.CollectedField, obj *HTTPRequest) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpRequest", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Method, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(HTTPMethod) - fc.Result = res - return ec.marshalNHttpMethod2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPMethod(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpRequest_proto(ctx context.Context, field graphql.CollectedField, obj *HTTPRequest) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpRequest", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Proto, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(HTTPProtocol) - fc.Result = res - return ec.marshalNHttpProtocol2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPProtocol(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpRequest_headers(ctx context.Context, field graphql.CollectedField, obj *HTTPRequest) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpRequest", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Headers, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]HTTPHeader) - fc.Result = res - return ec.marshalNHttpHeader2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPHeaderᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpRequest_body(ctx context.Context, field graphql.CollectedField, obj *HTTPRequest) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpRequest", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Body, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpRequest_response(ctx context.Context, field graphql.CollectedField, obj *HTTPRequest) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpRequest", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Response, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*HTTPResponse) - fc.Result = res - return ec.marshalOHttpResponse2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPResponse(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpRequestLog_id(ctx context.Context, field graphql.CollectedField, obj *HTTPRequestLog) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpRequestLog", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(ulid.ULID) - fc.Result = res - return ec.marshalNID2githubᚗcomᚋoklogᚋulidᚐULID(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpRequestLog_url(ctx context.Context, field graphql.CollectedField, obj *HTTPRequestLog) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpRequestLog", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.URL, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpRequestLog_method(ctx context.Context, field graphql.CollectedField, obj *HTTPRequestLog) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpRequestLog", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Method, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(HTTPMethod) - fc.Result = res - return ec.marshalNHttpMethod2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPMethod(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpRequestLog_proto(ctx context.Context, field graphql.CollectedField, obj *HTTPRequestLog) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpRequestLog", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Proto, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpRequestLog_headers(ctx context.Context, field graphql.CollectedField, obj *HTTPRequestLog) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpRequestLog", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Headers, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]HTTPHeader) - fc.Result = res - return ec.marshalNHttpHeader2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPHeaderᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpRequestLog_body(ctx context.Context, field graphql.CollectedField, obj *HTTPRequestLog) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpRequestLog", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Body, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpRequestLog_timestamp(ctx context.Context, field graphql.CollectedField, obj *HTTPRequestLog) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpRequestLog", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Timestamp, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(time.Time) - fc.Result = res - return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpRequestLog_response(ctx context.Context, field graphql.CollectedField, obj *HTTPRequestLog) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpRequestLog", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Response, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*HTTPResponseLog) - fc.Result = res - return ec.marshalOHttpResponseLog2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPResponseLog(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpRequestLogFilter_onlyInScope(ctx context.Context, field graphql.CollectedField, obj *HTTPRequestLogFilter) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpRequestLogFilter", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.OnlyInScope, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpRequestLogFilter_searchExpression(ctx context.Context, field graphql.CollectedField, obj *HTTPRequestLogFilter) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpRequestLogFilter", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SearchExpression, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpResponse_id(ctx context.Context, field graphql.CollectedField, obj *HTTPResponse) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpResponse", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(ulid.ULID) - fc.Result = res - return ec.marshalNID2githubᚗcomᚋoklogᚋulidᚐULID(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpResponse_proto(ctx context.Context, field graphql.CollectedField, obj *HTTPResponse) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpResponse", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Proto, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(HTTPProtocol) - fc.Result = res - return ec.marshalNHttpProtocol2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPProtocol(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpResponse_statusCode(ctx context.Context, field graphql.CollectedField, obj *HTTPResponse) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpResponse", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.StatusCode, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpResponse_statusReason(ctx context.Context, field graphql.CollectedField, obj *HTTPResponse) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpResponse", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.StatusReason, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpResponse_body(ctx context.Context, field graphql.CollectedField, obj *HTTPResponse) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpResponse", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Body, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpResponse_headers(ctx context.Context, field graphql.CollectedField, obj *HTTPResponse) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpResponse", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Headers, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]HTTPHeader) - fc.Result = res - return ec.marshalNHttpHeader2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPHeaderᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpResponseLog_id(ctx context.Context, field graphql.CollectedField, obj *HTTPResponseLog) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpResponseLog", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(ulid.ULID) - fc.Result = res - return ec.marshalNID2githubᚗcomᚋoklogᚋulidᚐULID(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpResponseLog_proto(ctx context.Context, field graphql.CollectedField, obj *HTTPResponseLog) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpResponseLog", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Proto, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(HTTPProtocol) - fc.Result = res - return ec.marshalNHttpProtocol2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPProtocol(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpResponseLog_statusCode(ctx context.Context, field graphql.CollectedField, obj *HTTPResponseLog) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpResponseLog", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.StatusCode, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpResponseLog_statusReason(ctx context.Context, field graphql.CollectedField, obj *HTTPResponseLog) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpResponseLog", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.StatusReason, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpResponseLog_body(ctx context.Context, field graphql.CollectedField, obj *HTTPResponseLog) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpResponseLog", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Body, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) _HttpResponseLog_headers(ctx context.Context, field graphql.CollectedField, obj *HTTPResponseLog) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "HttpResponseLog", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Headers, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]HTTPHeader) - fc.Result = res - return ec.marshalNHttpHeader2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPHeaderᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) _InterceptSettings_requestsEnabled(ctx context.Context, field graphql.CollectedField, obj *InterceptSettings) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "InterceptSettings", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.RequestsEnabled, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _InterceptSettings_responsesEnabled(ctx context.Context, field graphql.CollectedField, obj *InterceptSettings) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "InterceptSettings", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ResponsesEnabled, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _InterceptSettings_requestFilter(ctx context.Context, field graphql.CollectedField, obj *InterceptSettings) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "InterceptSettings", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.RequestFilter, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) _InterceptSettings_responseFilter(ctx context.Context, field graphql.CollectedField, obj *InterceptSettings) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "InterceptSettings", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ResponseFilter, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) _ModifyRequestResult_success(ctx context.Context, field graphql.CollectedField, obj *ModifyRequestResult) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "ModifyRequestResult", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Success, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _ModifyResponseResult_success(ctx context.Context, field graphql.CollectedField, obj *ModifyResponseResult) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "ModifyResponseResult", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Success, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_createProject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_createProject_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateProject(rctx, args["name"].(string)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Project) - fc.Result = res - return ec.marshalOProject2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐProject(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_openProject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_openProject_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().OpenProject(rctx, args["id"].(ulid.ULID)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Project) - fc.Result = res - return ec.marshalOProject2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐProject(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_closeProject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CloseProject(rctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*CloseProjectResult) - fc.Result = res - return ec.marshalNCloseProjectResult2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐCloseProjectResult(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_deleteProject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_deleteProject_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteProject(rctx, args["id"].(ulid.ULID)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*DeleteProjectResult) - fc.Result = res - return ec.marshalNDeleteProjectResult2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐDeleteProjectResult(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_clearHTTPRequestLog(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().ClearHTTPRequestLog(rctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*ClearHTTPRequestLogResult) - fc.Result = res - return ec.marshalNClearHTTPRequestLogResult2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐClearHTTPRequestLogResult(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_setScope(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_setScope_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().SetScope(rctx, args["scope"].([]ScopeRuleInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]ScopeRule) - fc.Result = res - return ec.marshalNScopeRule2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐScopeRuleᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_setHttpRequestLogFilter(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_setHttpRequestLogFilter_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().SetHTTPRequestLogFilter(rctx, args["filter"].(*HTTPRequestLogFilterInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*HTTPRequestLogFilter) - fc.Result = res - return ec.marshalOHttpRequestLogFilter2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPRequestLogFilter(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_setSenderRequestFilter(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_setSenderRequestFilter_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().SetSenderRequestFilter(rctx, args["filter"].(*SenderRequestFilterInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*SenderRequestFilter) - fc.Result = res - return ec.marshalOSenderRequestFilter2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐSenderRequestFilter(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_createOrUpdateSenderRequest(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_createOrUpdateSenderRequest_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateOrUpdateSenderRequest(rctx, args["request"].(SenderRequestInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*SenderRequest) - fc.Result = res - return ec.marshalNSenderRequest2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐSenderRequest(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_createSenderRequestFromHttpRequestLog(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_createSenderRequestFromHttpRequestLog_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateSenderRequestFromHTTPRequestLog(rctx, args["id"].(ulid.ULID)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*SenderRequest) - fc.Result = res - return ec.marshalNSenderRequest2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐSenderRequest(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_sendRequest(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_sendRequest_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().SendRequest(rctx, args["id"].(ulid.ULID)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*SenderRequest) - fc.Result = res - return ec.marshalNSenderRequest2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐSenderRequest(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_deleteSenderRequests(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteSenderRequests(rctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*DeleteSenderRequestsResult) - fc.Result = res - return ec.marshalNDeleteSenderRequestsResult2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐDeleteSenderRequestsResult(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_modifyRequest(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_modifyRequest_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().ModifyRequest(rctx, args["request"].(ModifyRequestInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*ModifyRequestResult) - fc.Result = res - return ec.marshalNModifyRequestResult2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐModifyRequestResult(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_cancelRequest(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_cancelRequest_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CancelRequest(rctx, args["id"].(ulid.ULID)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*CancelRequestResult) - fc.Result = res - return ec.marshalNCancelRequestResult2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐCancelRequestResult(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_modifyResponse(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_modifyResponse_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().ModifyResponse(rctx, args["response"].(ModifyResponseInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*ModifyResponseResult) - fc.Result = res - return ec.marshalNModifyResponseResult2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐModifyResponseResult(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_cancelResponse(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_cancelResponse_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CancelResponse(rctx, args["requestID"].(ulid.ULID)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*CancelResponseResult) - fc.Result = res - return ec.marshalNCancelResponseResult2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐCancelResponseResult(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_updateInterceptSettings(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_updateInterceptSettings_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateInterceptSettings(rctx, args["input"].(UpdateInterceptSettingsInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*InterceptSettings) - fc.Result = res - return ec.marshalNInterceptSettings2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐInterceptSettings(ctx, field.Selections, res) -} - -func (ec *executionContext) _Project_id(ctx context.Context, field graphql.CollectedField, obj *Project) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Project", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(ulid.ULID) - fc.Result = res - return ec.marshalNID2githubᚗcomᚋoklogᚋulidᚐULID(ctx, field.Selections, res) -} - -func (ec *executionContext) _Project_name(ctx context.Context, field graphql.CollectedField, obj *Project) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Project", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) _Project_isActive(ctx context.Context, field graphql.CollectedField, obj *Project) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Project", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsActive, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Project_settings(ctx context.Context, field graphql.CollectedField, obj *Project) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Project", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Settings, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*ProjectSettings) - fc.Result = res - return ec.marshalNProjectSettings2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐProjectSettings(ctx, field.Selections, res) -} - -func (ec *executionContext) _ProjectSettings_intercept(ctx context.Context, field graphql.CollectedField, obj *ProjectSettings) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "ProjectSettings", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Intercept, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*InterceptSettings) - fc.Result = res - return ec.marshalNInterceptSettings2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐInterceptSettings(ctx, field.Selections, res) -} - -func (ec *executionContext) _Query_httpRequestLog(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Query", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_httpRequestLog_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().HTTPRequestLog(rctx, args["id"].(ulid.ULID)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*HTTPRequestLog) - fc.Result = res - return ec.marshalOHttpRequestLog2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPRequestLog(ctx, field.Selections, res) -} - -func (ec *executionContext) _Query_httpRequestLogs(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Query", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().HTTPRequestLogs(rctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]HTTPRequestLog) - fc.Result = res - return ec.marshalNHttpRequestLog2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPRequestLogᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) _Query_httpRequestLogFilter(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Query", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().HTTPRequestLogFilter(rctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*HTTPRequestLogFilter) - fc.Result = res - return ec.marshalOHttpRequestLogFilter2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPRequestLogFilter(ctx, field.Selections, res) -} - -func (ec *executionContext) _Query_activeProject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Query", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().ActiveProject(rctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Project) - fc.Result = res - return ec.marshalOProject2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐProject(ctx, field.Selections, res) -} - -func (ec *executionContext) _Query_projects(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Query", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Projects(rctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]Project) - fc.Result = res - return ec.marshalNProject2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐProjectᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) _Query_scope(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Query", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Scope(rctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]ScopeRule) - fc.Result = res - return ec.marshalNScopeRule2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐScopeRuleᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) _Query_senderRequest(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Query", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_senderRequest_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().SenderRequest(rctx, args["id"].(ulid.ULID)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*SenderRequest) - fc.Result = res - return ec.marshalOSenderRequest2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐSenderRequest(ctx, field.Selections, res) -} - -func (ec *executionContext) _Query_senderRequests(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Query", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().SenderRequests(rctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]SenderRequest) - fc.Result = res - return ec.marshalNSenderRequest2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐSenderRequestᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) _Query_interceptedRequests(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Query", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().InterceptedRequests(rctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]HTTPRequest) - fc.Result = res - return ec.marshalNHttpRequest2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPRequestᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) _Query_interceptedRequest(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Query", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_interceptedRequest_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().InterceptedRequest(rctx, args["id"].(ulid.ULID)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*HTTPRequest) - fc.Result = res - return ec.marshalOHttpRequest2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPRequest(ctx, field.Selections, res) -} - -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Query", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query___type_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectType(args["name"].(string)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Query", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Schema) - fc.Result = res - return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) -} - -func (ec *executionContext) _ScopeHeader_key(ctx context.Context, field graphql.CollectedField, obj *ScopeHeader) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "ScopeHeader", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Key, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalORegexp2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) _ScopeHeader_value(ctx context.Context, field graphql.CollectedField, obj *ScopeHeader) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "ScopeHeader", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Value, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalORegexp2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) _ScopeRule_url(ctx context.Context, field graphql.CollectedField, obj *ScopeRule) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "ScopeRule", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.URL, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalORegexp2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) _ScopeRule_header(ctx context.Context, field graphql.CollectedField, obj *ScopeRule) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "ScopeRule", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Header, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*ScopeHeader) - fc.Result = res - return ec.marshalOScopeHeader2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐScopeHeader(ctx, field.Selections, res) -} - -func (ec *executionContext) _ScopeRule_body(ctx context.Context, field graphql.CollectedField, obj *ScopeRule) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "ScopeRule", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Body, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalORegexp2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) _SenderRequest_id(ctx context.Context, field graphql.CollectedField, obj *SenderRequest) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "SenderRequest", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(ulid.ULID) - fc.Result = res - return ec.marshalNID2githubᚗcomᚋoklogᚋulidᚐULID(ctx, field.Selections, res) -} - -func (ec *executionContext) _SenderRequest_sourceRequestLogID(ctx context.Context, field graphql.CollectedField, obj *SenderRequest) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "SenderRequest", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SourceRequestLogID, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*ulid.ULID) - fc.Result = res - return ec.marshalOID2ᚖgithubᚗcomᚋoklogᚋulidᚐULID(ctx, field.Selections, res) -} - -func (ec *executionContext) _SenderRequest_url(ctx context.Context, field graphql.CollectedField, obj *SenderRequest) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "SenderRequest", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.URL, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*url.URL) - fc.Result = res - return ec.marshalNURL2ᚖnetᚋurlᚐURL(ctx, field.Selections, res) -} - -func (ec *executionContext) _SenderRequest_method(ctx context.Context, field graphql.CollectedField, obj *SenderRequest) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "SenderRequest", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Method, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(HTTPMethod) - fc.Result = res - return ec.marshalNHttpMethod2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPMethod(ctx, field.Selections, res) -} - -func (ec *executionContext) _SenderRequest_proto(ctx context.Context, field graphql.CollectedField, obj *SenderRequest) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "SenderRequest", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Proto, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(HTTPProtocol) - fc.Result = res - return ec.marshalNHttpProtocol2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPProtocol(ctx, field.Selections, res) -} - -func (ec *executionContext) _SenderRequest_headers(ctx context.Context, field graphql.CollectedField, obj *SenderRequest) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "SenderRequest", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Headers, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]HTTPHeader) - fc.Result = res - return ec.marshalOHttpHeader2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPHeaderᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) _SenderRequest_body(ctx context.Context, field graphql.CollectedField, obj *SenderRequest) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "SenderRequest", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Body, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) _SenderRequest_timestamp(ctx context.Context, field graphql.CollectedField, obj *SenderRequest) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "SenderRequest", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Timestamp, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(time.Time) - fc.Result = res - return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) -} - -func (ec *executionContext) _SenderRequest_response(ctx context.Context, field graphql.CollectedField, obj *SenderRequest) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "SenderRequest", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Response, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*HTTPResponseLog) - fc.Result = res - return ec.marshalOHttpResponseLog2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPResponseLog(ctx, field.Selections, res) -} - -func (ec *executionContext) _SenderRequestFilter_onlyInScope(ctx context.Context, field graphql.CollectedField, obj *SenderRequestFilter) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "SenderRequestFilter", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.OnlyInScope, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _SenderRequestFilter_searchExpression(ctx context.Context, field graphql.CollectedField, obj *SenderRequestFilter) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "SenderRequestFilter", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SearchExpression, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Directive", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Directive", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Directive", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Locations, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]string) - fc.Result = res - return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Directive", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Args, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Directive", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsRepeatable, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Field", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Field", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Field", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Args, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Field", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Field", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Field", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Schema", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Types(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Schema", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Schema", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Schema", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Schema", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.Directive) - fc.Result = res - return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Type", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalN__TypeKind2string(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Type", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Type", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Type", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_fields_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Fields(args["includeDeprecated"].(bool)), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Field) - fc.Result = res - return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Type", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Type", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Type", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_enumValues_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.EnumValues(args["includeDeprecated"].(bool)), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.EnumValue) - fc.Result = res - return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Type", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - fc.Result = res - return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "__Type", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -// endregion **************************** field.gotpl ***************************** - -// region **************************** input.gotpl ***************************** - -func (ec *executionContext) unmarshalInputHttpHeaderInput(ctx context.Context, obj interface{}) (HTTPHeaderInput, error) { - var it HTTPHeaderInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - for k, v := range asMap { - switch k { - case "key": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("key")) - it.Key, err = ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - case "value": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value")) - it.Value, err = ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputHttpRequestLogFilterInput(ctx context.Context, obj interface{}) (HTTPRequestLogFilterInput, error) { - var it HTTPRequestLogFilterInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - for k, v := range asMap { - switch k { - case "onlyInScope": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("onlyInScope")) - it.OnlyInScope, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - case "searchExpression": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("searchExpression")) - it.SearchExpression, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputModifyRequestInput(ctx context.Context, obj interface{}) (ModifyRequestInput, error) { - var it ModifyRequestInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - for k, v := range asMap { - switch k { - case "id": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalNID2githubᚗcomᚋoklogᚋulidᚐULID(ctx, v) - if err != nil { - return it, err - } - case "url": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("url")) - it.URL, err = ec.unmarshalNURL2ᚖnetᚋurlᚐURL(ctx, v) - if err != nil { - return it, err - } - case "method": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("method")) - it.Method, err = ec.unmarshalNHttpMethod2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPMethod(ctx, v) - if err != nil { - return it, err - } - case "proto": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("proto")) - it.Proto, err = ec.unmarshalNHttpProtocol2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPProtocol(ctx, v) - if err != nil { - return it, err - } - case "headers": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("headers")) - it.Headers, err = ec.unmarshalOHttpHeaderInput2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPHeaderInputᚄ(ctx, v) - if err != nil { - return it, err - } - case "body": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("body")) - it.Body, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - case "modifyResponse": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("modifyResponse")) - it.ModifyResponse, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputModifyResponseInput(ctx context.Context, obj interface{}) (ModifyResponseInput, error) { - var it ModifyResponseInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - for k, v := range asMap { - switch k { - case "requestID": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("requestID")) - it.RequestID, err = ec.unmarshalNID2githubᚗcomᚋoklogᚋulidᚐULID(ctx, v) - if err != nil { - return it, err - } - case "proto": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("proto")) - it.Proto, err = ec.unmarshalNHttpProtocol2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPProtocol(ctx, v) - if err != nil { - return it, err - } - case "headers": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("headers")) - it.Headers, err = ec.unmarshalOHttpHeaderInput2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPHeaderInputᚄ(ctx, v) - if err != nil { - return it, err - } - case "body": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("body")) - it.Body, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - case "statusCode": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusCode")) - it.StatusCode, err = ec.unmarshalNInt2int(ctx, v) - if err != nil { - return it, err - } - case "statusReason": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusReason")) - it.StatusReason, err = ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputScopeHeaderInput(ctx context.Context, obj interface{}) (ScopeHeaderInput, error) { - var it ScopeHeaderInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - for k, v := range asMap { - switch k { - case "key": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("key")) - it.Key, err = ec.unmarshalORegexp2ᚖstring(ctx, v) - if err != nil { - return it, err - } - case "value": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value")) - it.Value, err = ec.unmarshalORegexp2ᚖstring(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputScopeRuleInput(ctx context.Context, obj interface{}) (ScopeRuleInput, error) { - var it ScopeRuleInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - for k, v := range asMap { - switch k { - case "url": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("url")) - it.URL, err = ec.unmarshalORegexp2ᚖstring(ctx, v) - if err != nil { - return it, err - } - case "header": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("header")) - it.Header, err = ec.unmarshalOScopeHeaderInput2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐScopeHeaderInput(ctx, v) - if err != nil { - return it, err - } - case "body": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("body")) - it.Body, err = ec.unmarshalORegexp2ᚖstring(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputSenderRequestFilterInput(ctx context.Context, obj interface{}) (SenderRequestFilterInput, error) { - var it SenderRequestFilterInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - for k, v := range asMap { - switch k { - case "onlyInScope": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("onlyInScope")) - it.OnlyInScope, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - case "searchExpression": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("searchExpression")) - it.SearchExpression, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputSenderRequestInput(ctx context.Context, obj interface{}) (SenderRequestInput, error) { - var it SenderRequestInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - for k, v := range asMap { - switch k { - case "id": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalOID2ᚖgithubᚗcomᚋoklogᚋulidᚐULID(ctx, v) - if err != nil { - return it, err - } - case "url": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("url")) - it.URL, err = ec.unmarshalNURL2ᚖnetᚋurlᚐURL(ctx, v) - if err != nil { - return it, err - } - case "method": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("method")) - it.Method, err = ec.unmarshalOHttpMethod2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPMethod(ctx, v) - if err != nil { - return it, err - } - case "proto": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("proto")) - it.Proto, err = ec.unmarshalOHttpProtocol2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPProtocol(ctx, v) - if err != nil { - return it, err - } - case "headers": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("headers")) - it.Headers, err = ec.unmarshalOHttpHeaderInput2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPHeaderInputᚄ(ctx, v) - if err != nil { - return it, err - } - case "body": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("body")) - it.Body, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputUpdateInterceptSettingsInput(ctx context.Context, obj interface{}) (UpdateInterceptSettingsInput, error) { - var it UpdateInterceptSettingsInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - for k, v := range asMap { - switch k { - case "requestsEnabled": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("requestsEnabled")) - it.RequestsEnabled, err = ec.unmarshalNBoolean2bool(ctx, v) - if err != nil { - return it, err - } - case "responsesEnabled": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("responsesEnabled")) - it.ResponsesEnabled, err = ec.unmarshalNBoolean2bool(ctx, v) - if err != nil { - return it, err - } - case "requestFilter": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("requestFilter")) - it.RequestFilter, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - case "responseFilter": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("responseFilter")) - it.ResponseFilter, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -// endregion **************************** input.gotpl ***************************** - -// region ************************** interface.gotpl *************************** - -// endregion ************************** interface.gotpl *************************** - -// region **************************** object.gotpl **************************** - -var cancelRequestResultImplementors = []string{"CancelRequestResult"} - -func (ec *executionContext) _CancelRequestResult(ctx context.Context, sel ast.SelectionSet, obj *CancelRequestResult) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, cancelRequestResultImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("CancelRequestResult") - case "success": - out.Values[i] = ec._CancelRequestResult_success(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var cancelResponseResultImplementors = []string{"CancelResponseResult"} - -func (ec *executionContext) _CancelResponseResult(ctx context.Context, sel ast.SelectionSet, obj *CancelResponseResult) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, cancelResponseResultImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("CancelResponseResult") - case "success": - out.Values[i] = ec._CancelResponseResult_success(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var clearHTTPRequestLogResultImplementors = []string{"ClearHTTPRequestLogResult"} - -func (ec *executionContext) _ClearHTTPRequestLogResult(ctx context.Context, sel ast.SelectionSet, obj *ClearHTTPRequestLogResult) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, clearHTTPRequestLogResultImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("ClearHTTPRequestLogResult") - case "success": - out.Values[i] = ec._ClearHTTPRequestLogResult_success(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var closeProjectResultImplementors = []string{"CloseProjectResult"} - -func (ec *executionContext) _CloseProjectResult(ctx context.Context, sel ast.SelectionSet, obj *CloseProjectResult) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, closeProjectResultImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("CloseProjectResult") - case "success": - out.Values[i] = ec._CloseProjectResult_success(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var deleteProjectResultImplementors = []string{"DeleteProjectResult"} - -func (ec *executionContext) _DeleteProjectResult(ctx context.Context, sel ast.SelectionSet, obj *DeleteProjectResult) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, deleteProjectResultImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("DeleteProjectResult") - case "success": - out.Values[i] = ec._DeleteProjectResult_success(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var deleteSenderRequestsResultImplementors = []string{"DeleteSenderRequestsResult"} - -func (ec *executionContext) _DeleteSenderRequestsResult(ctx context.Context, sel ast.SelectionSet, obj *DeleteSenderRequestsResult) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, deleteSenderRequestsResultImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("DeleteSenderRequestsResult") - case "success": - out.Values[i] = ec._DeleteSenderRequestsResult_success(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var httpHeaderImplementors = []string{"HttpHeader"} - -func (ec *executionContext) _HttpHeader(ctx context.Context, sel ast.SelectionSet, obj *HTTPHeader) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, httpHeaderImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("HttpHeader") - case "key": - out.Values[i] = ec._HttpHeader_key(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "value": - out.Values[i] = ec._HttpHeader_value(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var httpRequestImplementors = []string{"HttpRequest"} - -func (ec *executionContext) _HttpRequest(ctx context.Context, sel ast.SelectionSet, obj *HTTPRequest) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, httpRequestImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("HttpRequest") - case "id": - out.Values[i] = ec._HttpRequest_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "url": - out.Values[i] = ec._HttpRequest_url(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "method": - out.Values[i] = ec._HttpRequest_method(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "proto": - out.Values[i] = ec._HttpRequest_proto(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "headers": - out.Values[i] = ec._HttpRequest_headers(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "body": - out.Values[i] = ec._HttpRequest_body(ctx, field, obj) - case "response": - out.Values[i] = ec._HttpRequest_response(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var httpRequestLogImplementors = []string{"HttpRequestLog"} - -func (ec *executionContext) _HttpRequestLog(ctx context.Context, sel ast.SelectionSet, obj *HTTPRequestLog) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, httpRequestLogImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("HttpRequestLog") - case "id": - out.Values[i] = ec._HttpRequestLog_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "url": - out.Values[i] = ec._HttpRequestLog_url(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "method": - out.Values[i] = ec._HttpRequestLog_method(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "proto": - out.Values[i] = ec._HttpRequestLog_proto(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "headers": - out.Values[i] = ec._HttpRequestLog_headers(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "body": - out.Values[i] = ec._HttpRequestLog_body(ctx, field, obj) - case "timestamp": - out.Values[i] = ec._HttpRequestLog_timestamp(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "response": - out.Values[i] = ec._HttpRequestLog_response(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var httpRequestLogFilterImplementors = []string{"HttpRequestLogFilter"} - -func (ec *executionContext) _HttpRequestLogFilter(ctx context.Context, sel ast.SelectionSet, obj *HTTPRequestLogFilter) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, httpRequestLogFilterImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("HttpRequestLogFilter") - case "onlyInScope": - out.Values[i] = ec._HttpRequestLogFilter_onlyInScope(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "searchExpression": - out.Values[i] = ec._HttpRequestLogFilter_searchExpression(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var httpResponseImplementors = []string{"HttpResponse"} - -func (ec *executionContext) _HttpResponse(ctx context.Context, sel ast.SelectionSet, obj *HTTPResponse) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, httpResponseImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("HttpResponse") - case "id": - out.Values[i] = ec._HttpResponse_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "proto": - out.Values[i] = ec._HttpResponse_proto(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "statusCode": - out.Values[i] = ec._HttpResponse_statusCode(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "statusReason": - out.Values[i] = ec._HttpResponse_statusReason(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "body": - out.Values[i] = ec._HttpResponse_body(ctx, field, obj) - case "headers": - out.Values[i] = ec._HttpResponse_headers(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var httpResponseLogImplementors = []string{"HttpResponseLog"} - -func (ec *executionContext) _HttpResponseLog(ctx context.Context, sel ast.SelectionSet, obj *HTTPResponseLog) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, httpResponseLogImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("HttpResponseLog") - case "id": - out.Values[i] = ec._HttpResponseLog_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "proto": - out.Values[i] = ec._HttpResponseLog_proto(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "statusCode": - out.Values[i] = ec._HttpResponseLog_statusCode(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "statusReason": - out.Values[i] = ec._HttpResponseLog_statusReason(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "body": - out.Values[i] = ec._HttpResponseLog_body(ctx, field, obj) - case "headers": - out.Values[i] = ec._HttpResponseLog_headers(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var interceptSettingsImplementors = []string{"InterceptSettings"} - -func (ec *executionContext) _InterceptSettings(ctx context.Context, sel ast.SelectionSet, obj *InterceptSettings) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, interceptSettingsImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("InterceptSettings") - case "requestsEnabled": - out.Values[i] = ec._InterceptSettings_requestsEnabled(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "responsesEnabled": - out.Values[i] = ec._InterceptSettings_responsesEnabled(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "requestFilter": - out.Values[i] = ec._InterceptSettings_requestFilter(ctx, field, obj) - case "responseFilter": - out.Values[i] = ec._InterceptSettings_responseFilter(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var modifyRequestResultImplementors = []string{"ModifyRequestResult"} - -func (ec *executionContext) _ModifyRequestResult(ctx context.Context, sel ast.SelectionSet, obj *ModifyRequestResult) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, modifyRequestResultImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("ModifyRequestResult") - case "success": - out.Values[i] = ec._ModifyRequestResult_success(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var modifyResponseResultImplementors = []string{"ModifyResponseResult"} - -func (ec *executionContext) _ModifyResponseResult(ctx context.Context, sel ast.SelectionSet, obj *ModifyResponseResult) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, modifyResponseResultImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("ModifyResponseResult") - case "success": - out.Values[i] = ec._ModifyResponseResult_success(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var mutationImplementors = []string{"Mutation"} - -func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors) - - ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ - Object: "Mutation", - }) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Mutation") - case "createProject": - out.Values[i] = ec._Mutation_createProject(ctx, field) - case "openProject": - out.Values[i] = ec._Mutation_openProject(ctx, field) - case "closeProject": - out.Values[i] = ec._Mutation_closeProject(ctx, field) - if out.Values[i] == graphql.Null { - invalids++ - } - case "deleteProject": - out.Values[i] = ec._Mutation_deleteProject(ctx, field) - if out.Values[i] == graphql.Null { - invalids++ - } - case "clearHTTPRequestLog": - out.Values[i] = ec._Mutation_clearHTTPRequestLog(ctx, field) - if out.Values[i] == graphql.Null { - invalids++ - } - case "setScope": - out.Values[i] = ec._Mutation_setScope(ctx, field) - if out.Values[i] == graphql.Null { - invalids++ - } - case "setHttpRequestLogFilter": - out.Values[i] = ec._Mutation_setHttpRequestLogFilter(ctx, field) - case "setSenderRequestFilter": - out.Values[i] = ec._Mutation_setSenderRequestFilter(ctx, field) - case "createOrUpdateSenderRequest": - out.Values[i] = ec._Mutation_createOrUpdateSenderRequest(ctx, field) - if out.Values[i] == graphql.Null { - invalids++ - } - case "createSenderRequestFromHttpRequestLog": - out.Values[i] = ec._Mutation_createSenderRequestFromHttpRequestLog(ctx, field) - if out.Values[i] == graphql.Null { - invalids++ - } - case "sendRequest": - out.Values[i] = ec._Mutation_sendRequest(ctx, field) - if out.Values[i] == graphql.Null { - invalids++ - } - case "deleteSenderRequests": - out.Values[i] = ec._Mutation_deleteSenderRequests(ctx, field) - if out.Values[i] == graphql.Null { - invalids++ - } - case "modifyRequest": - out.Values[i] = ec._Mutation_modifyRequest(ctx, field) - if out.Values[i] == graphql.Null { - invalids++ - } - case "cancelRequest": - out.Values[i] = ec._Mutation_cancelRequest(ctx, field) - if out.Values[i] == graphql.Null { - invalids++ - } - case "modifyResponse": - out.Values[i] = ec._Mutation_modifyResponse(ctx, field) - if out.Values[i] == graphql.Null { - invalids++ - } - case "cancelResponse": - out.Values[i] = ec._Mutation_cancelResponse(ctx, field) - if out.Values[i] == graphql.Null { - invalids++ - } - case "updateInterceptSettings": - out.Values[i] = ec._Mutation_updateInterceptSettings(ctx, field) - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var projectImplementors = []string{"Project"} - -func (ec *executionContext) _Project(ctx context.Context, sel ast.SelectionSet, obj *Project) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, projectImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Project") - case "id": - out.Values[i] = ec._Project_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "name": - out.Values[i] = ec._Project_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "isActive": - out.Values[i] = ec._Project_isActive(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "settings": - out.Values[i] = ec._Project_settings(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var projectSettingsImplementors = []string{"ProjectSettings"} - -func (ec *executionContext) _ProjectSettings(ctx context.Context, sel ast.SelectionSet, obj *ProjectSettings) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, projectSettingsImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("ProjectSettings") - case "intercept": - out.Values[i] = ec._ProjectSettings_intercept(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var queryImplementors = []string{"Query"} - -func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) - - ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ - Object: "Query", - }) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Query") - case "httpRequestLog": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_httpRequestLog(ctx, field) - return res - }) - case "httpRequestLogs": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_httpRequestLogs(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - }) - case "httpRequestLogFilter": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_httpRequestLogFilter(ctx, field) - return res - }) - case "activeProject": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_activeProject(ctx, field) - return res - }) - case "projects": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_projects(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - }) - case "scope": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_scope(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - }) - case "senderRequest": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_senderRequest(ctx, field) - return res - }) - case "senderRequests": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_senderRequests(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - }) - case "interceptedRequests": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_interceptedRequests(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - }) - case "interceptedRequest": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_interceptedRequest(ctx, field) - return res - }) - case "__type": - out.Values[i] = ec._Query___type(ctx, field) - case "__schema": - out.Values[i] = ec._Query___schema(ctx, field) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var scopeHeaderImplementors = []string{"ScopeHeader"} - -func (ec *executionContext) _ScopeHeader(ctx context.Context, sel ast.SelectionSet, obj *ScopeHeader) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, scopeHeaderImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("ScopeHeader") - case "key": - out.Values[i] = ec._ScopeHeader_key(ctx, field, obj) - case "value": - out.Values[i] = ec._ScopeHeader_value(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var scopeRuleImplementors = []string{"ScopeRule"} - -func (ec *executionContext) _ScopeRule(ctx context.Context, sel ast.SelectionSet, obj *ScopeRule) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, scopeRuleImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("ScopeRule") - case "url": - out.Values[i] = ec._ScopeRule_url(ctx, field, obj) - case "header": - out.Values[i] = ec._ScopeRule_header(ctx, field, obj) - case "body": - out.Values[i] = ec._ScopeRule_body(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var senderRequestImplementors = []string{"SenderRequest"} - -func (ec *executionContext) _SenderRequest(ctx context.Context, sel ast.SelectionSet, obj *SenderRequest) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, senderRequestImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("SenderRequest") - case "id": - out.Values[i] = ec._SenderRequest_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "sourceRequestLogID": - out.Values[i] = ec._SenderRequest_sourceRequestLogID(ctx, field, obj) - case "url": - out.Values[i] = ec._SenderRequest_url(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "method": - out.Values[i] = ec._SenderRequest_method(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "proto": - out.Values[i] = ec._SenderRequest_proto(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "headers": - out.Values[i] = ec._SenderRequest_headers(ctx, field, obj) - case "body": - out.Values[i] = ec._SenderRequest_body(ctx, field, obj) - case "timestamp": - out.Values[i] = ec._SenderRequest_timestamp(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "response": - out.Values[i] = ec._SenderRequest_response(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var senderRequestFilterImplementors = []string{"SenderRequestFilter"} - -func (ec *executionContext) _SenderRequestFilter(ctx context.Context, sel ast.SelectionSet, obj *SenderRequestFilter) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, senderRequestFilterImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("SenderRequestFilter") - case "onlyInScope": - out.Values[i] = ec._SenderRequestFilter_onlyInScope(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "searchExpression": - out.Values[i] = ec._SenderRequestFilter_searchExpression(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __DirectiveImplementors = []string{"__Directive"} - -func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Directive") - case "name": - out.Values[i] = ec.___Directive_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "description": - out.Values[i] = ec.___Directive_description(ctx, field, obj) - case "locations": - out.Values[i] = ec.___Directive_locations(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "args": - out.Values[i] = ec.___Directive_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "isRepeatable": - out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __EnumValueImplementors = []string{"__EnumValue"} - -func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__EnumValue") - case "name": - out.Values[i] = ec.___EnumValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "description": - out.Values[i] = ec.___EnumValue_description(ctx, field, obj) - case "isDeprecated": - out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "deprecationReason": - out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __FieldImplementors = []string{"__Field"} - -func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Field") - case "name": - out.Values[i] = ec.___Field_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "description": - out.Values[i] = ec.___Field_description(ctx, field, obj) - case "args": - out.Values[i] = ec.___Field_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "type": - out.Values[i] = ec.___Field_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "isDeprecated": - out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "deprecationReason": - out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __InputValueImplementors = []string{"__InputValue"} - -func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__InputValue") - case "name": - out.Values[i] = ec.___InputValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "description": - out.Values[i] = ec.___InputValue_description(ctx, field, obj) - case "type": - out.Values[i] = ec.___InputValue_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "defaultValue": - out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __SchemaImplementors = []string{"__Schema"} - -func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Schema") - case "types": - out.Values[i] = ec.___Schema_types(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "queryType": - out.Values[i] = ec.___Schema_queryType(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "mutationType": - out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) - case "subscriptionType": - out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) - case "directives": - out.Values[i] = ec.___Schema_directives(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var __TypeImplementors = []string{"__Type"} - -func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Type") - case "kind": - out.Values[i] = ec.___Type_kind(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "name": - out.Values[i] = ec.___Type_name(ctx, field, obj) - case "description": - out.Values[i] = ec.___Type_description(ctx, field, obj) - case "fields": - out.Values[i] = ec.___Type_fields(ctx, field, obj) - case "interfaces": - out.Values[i] = ec.___Type_interfaces(ctx, field, obj) - case "possibleTypes": - out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) - case "enumValues": - out.Values[i] = ec.___Type_enumValues(ctx, field, obj) - case "inputFields": - out.Values[i] = ec.___Type_inputFields(ctx, field, obj) - case "ofType": - out.Values[i] = ec.___Type_ofType(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -// endregion **************************** object.gotpl **************************** - -// region ***************************** type.gotpl ***************************** - -func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { - res, err := graphql.UnmarshalBoolean(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - } - return res -} - -func (ec *executionContext) marshalNCancelRequestResult2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐCancelRequestResult(ctx context.Context, sel ast.SelectionSet, v CancelRequestResult) graphql.Marshaler { - return ec._CancelRequestResult(ctx, sel, &v) -} - -func (ec *executionContext) marshalNCancelRequestResult2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐCancelRequestResult(ctx context.Context, sel ast.SelectionSet, v *CancelRequestResult) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._CancelRequestResult(ctx, sel, v) -} - -func (ec *executionContext) marshalNCancelResponseResult2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐCancelResponseResult(ctx context.Context, sel ast.SelectionSet, v CancelResponseResult) graphql.Marshaler { - return ec._CancelResponseResult(ctx, sel, &v) -} - -func (ec *executionContext) marshalNCancelResponseResult2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐCancelResponseResult(ctx context.Context, sel ast.SelectionSet, v *CancelResponseResult) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._CancelResponseResult(ctx, sel, v) -} - -func (ec *executionContext) marshalNClearHTTPRequestLogResult2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐClearHTTPRequestLogResult(ctx context.Context, sel ast.SelectionSet, v ClearHTTPRequestLogResult) graphql.Marshaler { - return ec._ClearHTTPRequestLogResult(ctx, sel, &v) -} - -func (ec *executionContext) marshalNClearHTTPRequestLogResult2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐClearHTTPRequestLogResult(ctx context.Context, sel ast.SelectionSet, v *ClearHTTPRequestLogResult) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._ClearHTTPRequestLogResult(ctx, sel, v) -} - -func (ec *executionContext) marshalNCloseProjectResult2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐCloseProjectResult(ctx context.Context, sel ast.SelectionSet, v CloseProjectResult) graphql.Marshaler { - return ec._CloseProjectResult(ctx, sel, &v) -} - -func (ec *executionContext) marshalNCloseProjectResult2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐCloseProjectResult(ctx context.Context, sel ast.SelectionSet, v *CloseProjectResult) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._CloseProjectResult(ctx, sel, v) -} - -func (ec *executionContext) marshalNDeleteProjectResult2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐDeleteProjectResult(ctx context.Context, sel ast.SelectionSet, v DeleteProjectResult) graphql.Marshaler { - return ec._DeleteProjectResult(ctx, sel, &v) -} - -func (ec *executionContext) marshalNDeleteProjectResult2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐDeleteProjectResult(ctx context.Context, sel ast.SelectionSet, v *DeleteProjectResult) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._DeleteProjectResult(ctx, sel, v) -} - -func (ec *executionContext) marshalNDeleteSenderRequestsResult2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐDeleteSenderRequestsResult(ctx context.Context, sel ast.SelectionSet, v DeleteSenderRequestsResult) graphql.Marshaler { - return ec._DeleteSenderRequestsResult(ctx, sel, &v) -} - -func (ec *executionContext) marshalNDeleteSenderRequestsResult2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐDeleteSenderRequestsResult(ctx context.Context, sel ast.SelectionSet, v *DeleteSenderRequestsResult) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._DeleteSenderRequestsResult(ctx, sel, v) -} - -func (ec *executionContext) marshalNHttpHeader2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPHeader(ctx context.Context, sel ast.SelectionSet, v HTTPHeader) graphql.Marshaler { - return ec._HttpHeader(ctx, sel, &v) -} - -func (ec *executionContext) marshalNHttpHeader2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPHeaderᚄ(ctx context.Context, sel ast.SelectionSet, v []HTTPHeader) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNHttpHeader2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPHeader(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalNHttpHeaderInput2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPHeaderInput(ctx context.Context, v interface{}) (HTTPHeaderInput, error) { - res, err := ec.unmarshalInputHttpHeaderInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalNHttpMethod2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPMethod(ctx context.Context, v interface{}) (HTTPMethod, error) { - var res HTTPMethod - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNHttpMethod2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPMethod(ctx context.Context, sel ast.SelectionSet, v HTTPMethod) graphql.Marshaler { - return v -} - -func (ec *executionContext) unmarshalNHttpProtocol2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPProtocol(ctx context.Context, v interface{}) (HTTPProtocol, error) { - var res HTTPProtocol - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNHttpProtocol2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPProtocol(ctx context.Context, sel ast.SelectionSet, v HTTPProtocol) graphql.Marshaler { - return v -} - -func (ec *executionContext) marshalNHttpRequest2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPRequest(ctx context.Context, sel ast.SelectionSet, v HTTPRequest) graphql.Marshaler { - return ec._HttpRequest(ctx, sel, &v) -} - -func (ec *executionContext) marshalNHttpRequest2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPRequestᚄ(ctx context.Context, sel ast.SelectionSet, v []HTTPRequest) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNHttpRequest2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPRequest(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalNHttpRequestLog2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPRequestLog(ctx context.Context, sel ast.SelectionSet, v HTTPRequestLog) graphql.Marshaler { - return ec._HttpRequestLog(ctx, sel, &v) -} - -func (ec *executionContext) marshalNHttpRequestLog2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPRequestLogᚄ(ctx context.Context, sel ast.SelectionSet, v []HTTPRequestLog) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNHttpRequestLog2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPRequestLog(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalNID2githubᚗcomᚋoklogᚋulidᚐULID(ctx context.Context, v interface{}) (ulid.ULID, error) { - res, err := UnmarshalULID(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNID2githubᚗcomᚋoklogᚋulidᚐULID(ctx context.Context, sel ast.SelectionSet, v ulid.ULID) graphql.Marshaler { - res := MarshalULID(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - } - return res -} - -func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) { - res, err := graphql.UnmarshalInt(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - res := graphql.MarshalInt(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - } - return res -} - -func (ec *executionContext) marshalNInterceptSettings2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐInterceptSettings(ctx context.Context, sel ast.SelectionSet, v InterceptSettings) graphql.Marshaler { - return ec._InterceptSettings(ctx, sel, &v) -} - -func (ec *executionContext) marshalNInterceptSettings2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐInterceptSettings(ctx context.Context, sel ast.SelectionSet, v *InterceptSettings) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._InterceptSettings(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNModifyRequestInput2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐModifyRequestInput(ctx context.Context, v interface{}) (ModifyRequestInput, error) { - res, err := ec.unmarshalInputModifyRequestInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNModifyRequestResult2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐModifyRequestResult(ctx context.Context, sel ast.SelectionSet, v ModifyRequestResult) graphql.Marshaler { - return ec._ModifyRequestResult(ctx, sel, &v) -} - -func (ec *executionContext) marshalNModifyRequestResult2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐModifyRequestResult(ctx context.Context, sel ast.SelectionSet, v *ModifyRequestResult) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._ModifyRequestResult(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNModifyResponseInput2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐModifyResponseInput(ctx context.Context, v interface{}) (ModifyResponseInput, error) { - res, err := ec.unmarshalInputModifyResponseInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNModifyResponseResult2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐModifyResponseResult(ctx context.Context, sel ast.SelectionSet, v ModifyResponseResult) graphql.Marshaler { - return ec._ModifyResponseResult(ctx, sel, &v) -} - -func (ec *executionContext) marshalNModifyResponseResult2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐModifyResponseResult(ctx context.Context, sel ast.SelectionSet, v *ModifyResponseResult) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._ModifyResponseResult(ctx, sel, v) -} - -func (ec *executionContext) marshalNProject2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐProject(ctx context.Context, sel ast.SelectionSet, v Project) graphql.Marshaler { - return ec._Project(ctx, sel, &v) -} - -func (ec *executionContext) marshalNProject2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐProjectᚄ(ctx context.Context, sel ast.SelectionSet, v []Project) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNProject2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐProject(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalNProjectSettings2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐProjectSettings(ctx context.Context, sel ast.SelectionSet, v *ProjectSettings) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._ProjectSettings(ctx, sel, v) -} - -func (ec *executionContext) marshalNScopeRule2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐScopeRule(ctx context.Context, sel ast.SelectionSet, v ScopeRule) graphql.Marshaler { - return ec._ScopeRule(ctx, sel, &v) -} - -func (ec *executionContext) marshalNScopeRule2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐScopeRuleᚄ(ctx context.Context, sel ast.SelectionSet, v []ScopeRule) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNScopeRule2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐScopeRule(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalNScopeRuleInput2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐScopeRuleInput(ctx context.Context, v interface{}) (ScopeRuleInput, error) { - res, err := ec.unmarshalInputScopeRuleInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalNScopeRuleInput2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐScopeRuleInputᚄ(ctx context.Context, v interface{}) ([]ScopeRuleInput, error) { - var vSlice []interface{} - if v != nil { - if tmp1, ok := v.([]interface{}); ok { - vSlice = tmp1 - } else { - vSlice = []interface{}{v} - } - } - var err error - res := make([]ScopeRuleInput, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNScopeRuleInput2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐScopeRuleInput(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalNSenderRequest2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐSenderRequest(ctx context.Context, sel ast.SelectionSet, v SenderRequest) graphql.Marshaler { - return ec._SenderRequest(ctx, sel, &v) -} - -func (ec *executionContext) marshalNSenderRequest2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐSenderRequestᚄ(ctx context.Context, sel ast.SelectionSet, v []SenderRequest) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNSenderRequest2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐSenderRequest(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalNSenderRequest2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐSenderRequest(ctx context.Context, sel ast.SelectionSet, v *SenderRequest) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._SenderRequest(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNSenderRequestInput2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐSenderRequestInput(ctx context.Context, v interface{}) (SenderRequestInput, error) { - res, err := ec.unmarshalInputSenderRequestInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - } - return res -} - -func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v interface{}) (time.Time, error) { - res, err := graphql.UnmarshalTime(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - res := graphql.MarshalTime(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - } - return res -} - -func (ec *executionContext) unmarshalNURL2ᚖnetᚋurlᚐURL(ctx context.Context, v interface{}) (*url.URL, error) { - res, err := UnmarshalURL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNURL2ᚖnetᚋurlᚐURL(ctx context.Context, sel ast.SelectionSet, v *url.URL) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := MarshalURL(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - } - return res -} - -func (ec *executionContext) unmarshalNUpdateInterceptSettingsInput2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐUpdateInterceptSettingsInput(ctx context.Context, v interface{}) (UpdateInterceptSettingsInput, error) { - res, err := ec.unmarshalInputUpdateInterceptSettingsInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - } - return res -} - -func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - var vSlice []interface{} - if v != nil { - if tmp1, ok := v.([]interface{}); ok { - vSlice = tmp1 - } else { - vSlice = []interface{}{v} - } - } - var err error - res := make([]string, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec.___Type(ctx, sel, v) -} - -func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - } - return res -} - -func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { - res, err := graphql.UnmarshalBoolean(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) -} - -func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalBoolean(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return graphql.MarshalBoolean(*v) -} - -func (ec *executionContext) marshalOHttpHeader2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPHeaderᚄ(ctx context.Context, sel ast.SelectionSet, v []HTTPHeader) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNHttpHeader2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPHeader(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalOHttpHeaderInput2ᚕgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPHeaderInputᚄ(ctx context.Context, v interface{}) ([]HTTPHeaderInput, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - if tmp1, ok := v.([]interface{}); ok { - vSlice = tmp1 - } else { - vSlice = []interface{}{v} - } - } - var err error - res := make([]HTTPHeaderInput, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNHttpHeaderInput2githubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPHeaderInput(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) unmarshalOHttpMethod2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPMethod(ctx context.Context, v interface{}) (*HTTPMethod, error) { - if v == nil { - return nil, nil - } - var res = new(HTTPMethod) - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOHttpMethod2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPMethod(ctx context.Context, sel ast.SelectionSet, v *HTTPMethod) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return v -} - -func (ec *executionContext) unmarshalOHttpProtocol2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPProtocol(ctx context.Context, v interface{}) (*HTTPProtocol, error) { - if v == nil { - return nil, nil - } - var res = new(HTTPProtocol) - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOHttpProtocol2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPProtocol(ctx context.Context, sel ast.SelectionSet, v *HTTPProtocol) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return v -} - -func (ec *executionContext) marshalOHttpRequest2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPRequest(ctx context.Context, sel ast.SelectionSet, v *HTTPRequest) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._HttpRequest(ctx, sel, v) -} - -func (ec *executionContext) marshalOHttpRequestLog2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPRequestLog(ctx context.Context, sel ast.SelectionSet, v *HTTPRequestLog) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._HttpRequestLog(ctx, sel, v) -} - -func (ec *executionContext) marshalOHttpRequestLogFilter2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPRequestLogFilter(ctx context.Context, sel ast.SelectionSet, v *HTTPRequestLogFilter) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._HttpRequestLogFilter(ctx, sel, v) -} - -func (ec *executionContext) unmarshalOHttpRequestLogFilterInput2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPRequestLogFilterInput(ctx context.Context, v interface{}) (*HTTPRequestLogFilterInput, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputHttpRequestLogFilterInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOHttpResponse2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPResponse(ctx context.Context, sel ast.SelectionSet, v *HTTPResponse) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._HttpResponse(ctx, sel, v) -} - -func (ec *executionContext) marshalOHttpResponseLog2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐHTTPResponseLog(ctx context.Context, sel ast.SelectionSet, v *HTTPResponseLog) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._HttpResponseLog(ctx, sel, v) -} - -func (ec *executionContext) unmarshalOID2ᚖgithubᚗcomᚋoklogᚋulidᚐULID(ctx context.Context, v interface{}) (*ulid.ULID, error) { - if v == nil { - return nil, nil - } - res, err := UnmarshalULID(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOID2ᚖgithubᚗcomᚋoklogᚋulidᚐULID(ctx context.Context, sel ast.SelectionSet, v *ulid.ULID) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return MarshalULID(*v) -} - -func (ec *executionContext) marshalOProject2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐProject(ctx context.Context, sel ast.SelectionSet, v *Project) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._Project(ctx, sel, v) -} - -func (ec *executionContext) unmarshalORegexp2ᚖstring(ctx context.Context, v interface{}) (*string, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalString(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalORegexp2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return graphql.MarshalString(*v) -} - -func (ec *executionContext) marshalOScopeHeader2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐScopeHeader(ctx context.Context, sel ast.SelectionSet, v *ScopeHeader) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._ScopeHeader(ctx, sel, v) -} - -func (ec *executionContext) unmarshalOScopeHeaderInput2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐScopeHeaderInput(ctx context.Context, v interface{}) (*ScopeHeaderInput, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputScopeHeaderInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOSenderRequest2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐSenderRequest(ctx context.Context, sel ast.SelectionSet, v *SenderRequest) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._SenderRequest(ctx, sel, v) -} - -func (ec *executionContext) marshalOSenderRequestFilter2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐSenderRequestFilter(ctx context.Context, sel ast.SelectionSet, v *SenderRequestFilter) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._SenderRequestFilter(ctx, sel, v) -} - -func (ec *executionContext) unmarshalOSenderRequestFilterInput2ᚖgithubᚗcomᚋdstotijnᚋhettyᚋpkgᚋapiᚐSenderRequestFilterInput(ctx context.Context, v interface{}) (*SenderRequestFilterInput, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputSenderRequestFilterInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) -} - -func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalString(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return graphql.MarshalString(*v) -} - -func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Schema(ctx, sel, v) -} - -func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Type(ctx, sel, v) -} - -// endregion ***************************** type.gotpl ***************************** diff --git a/pkg/api/http.go b/pkg/api/http.go deleted file mode 100644 index 4d2a4fc..0000000 --- a/pkg/api/http.go +++ /dev/null @@ -1,21 +0,0 @@ -package api - -import ( - "net/http" - - "github.com/99designs/gqlgen/graphql/handler" - "github.com/99designs/gqlgen/graphql/playground" - "github.com/gorilla/mux" -) - -func HTTPHandler(resolver *Resolver, gqlEndpoint string) http.Handler { - router := mux.NewRouter().SkipClean(true) - router.Methods("POST").Handler( - handler.NewDefaultServer(NewExecutableSchema(Config{ - Resolvers: resolver, - })), - ) - router.Methods("GET").Handler(playground.Handler("GraphQL Playground", gqlEndpoint)) - - return router -} diff --git a/pkg/api/models.go b/pkg/api/models.go deleted file mode 100644 index 4d79c4a..0000000 --- a/pkg/api/models.go +++ /dev/null @@ -1,65 +0,0 @@ -package api - -import ( - "fmt" - "io" - "net/url" - "strconv" - - "github.com/99designs/gqlgen/graphql" - "github.com/oklog/ulid" -) - -func MarshalULID(u ulid.ULID) graphql.Marshaler { - return graphql.WriterFunc(func(w io.Writer) { - fmt.Fprint(w, strconv.Quote(u.String())) - }) -} - -func UnmarshalULID(v interface{}) (ulid.ULID, error) { - rawULID, ok := v.(string) - if !ok { - return ulid.ULID{}, fmt.Errorf("ulid must be a string") - } - - u, err := ulid.Parse(rawULID) - if err != nil { - return ulid.ULID{}, fmt.Errorf("failed to parse ULID: %w", err) - } - - return u, nil -} - -func MarshalURL(u *url.URL) graphql.Marshaler { - return graphql.WriterFunc(func(w io.Writer) { - fmt.Fprint(w, strconv.Quote(u.String())) - }) -} - -func UnmarshalURL(v interface{}) (*url.URL, error) { - rawURL, ok := v.(string) - if !ok { - return nil, fmt.Errorf("url must be a string") - } - - u, err := url.Parse(rawURL) - if err != nil { - return nil, fmt.Errorf("failed to parse URL: %w", err) - } - - return u, nil -} - -type HTTPHeaders []HTTPHeader - -func (h HTTPHeaders) Len() int { - return len(h) -} - -func (h HTTPHeaders) Less(i, j int) bool { - return h[i].Key < h[j].Key -} - -func (h HTTPHeaders) Swap(i, j int) { - h[i], h[j] = h[j], h[i] -} diff --git a/pkg/api/models_gen.go b/pkg/api/models_gen.go deleted file mode 100644 index 9c480b5..0000000 --- a/pkg/api/models_gen.go +++ /dev/null @@ -1,301 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package api - -import ( - "fmt" - "io" - "net/url" - "strconv" - "time" - - "github.com/oklog/ulid" -) - -type CancelRequestResult struct { - Success bool `json:"success"` -} - -type CancelResponseResult struct { - Success bool `json:"success"` -} - -type ClearHTTPRequestLogResult struct { - Success bool `json:"success"` -} - -type CloseProjectResult struct { - Success bool `json:"success"` -} - -type DeleteProjectResult struct { - Success bool `json:"success"` -} - -type DeleteSenderRequestsResult struct { - Success bool `json:"success"` -} - -type HTTPHeader struct { - Key string `json:"key"` - Value string `json:"value"` -} - -type HTTPHeaderInput struct { - Key string `json:"key"` - Value string `json:"value"` -} - -type HTTPRequest struct { - ID ulid.ULID `json:"id"` - URL *url.URL `json:"url"` - Method HTTPMethod `json:"method"` - Proto HTTPProtocol `json:"proto"` - Headers []HTTPHeader `json:"headers"` - Body *string `json:"body"` - Response *HTTPResponse `json:"response"` -} - -type HTTPRequestLog struct { - ID ulid.ULID `json:"id"` - URL string `json:"url"` - Method HTTPMethod `json:"method"` - Proto string `json:"proto"` - Headers []HTTPHeader `json:"headers"` - Body *string `json:"body"` - Timestamp time.Time `json:"timestamp"` - Response *HTTPResponseLog `json:"response"` -} - -type HTTPRequestLogFilter struct { - OnlyInScope bool `json:"onlyInScope"` - SearchExpression *string `json:"searchExpression"` -} - -type HTTPRequestLogFilterInput struct { - OnlyInScope *bool `json:"onlyInScope"` - SearchExpression *string `json:"searchExpression"` -} - -type HTTPResponse struct { - // Will be the same ID as its related request ID. - ID ulid.ULID `json:"id"` - Proto HTTPProtocol `json:"proto"` - StatusCode int `json:"statusCode"` - StatusReason string `json:"statusReason"` - Body *string `json:"body"` - Headers []HTTPHeader `json:"headers"` -} - -type HTTPResponseLog struct { - // Will be the same ID as its related request ID. - ID ulid.ULID `json:"id"` - Proto HTTPProtocol `json:"proto"` - StatusCode int `json:"statusCode"` - StatusReason string `json:"statusReason"` - Body *string `json:"body"` - Headers []HTTPHeader `json:"headers"` -} - -type InterceptSettings struct { - RequestsEnabled bool `json:"requestsEnabled"` - ResponsesEnabled bool `json:"responsesEnabled"` - RequestFilter *string `json:"requestFilter"` - ResponseFilter *string `json:"responseFilter"` -} - -type ModifyRequestInput struct { - ID ulid.ULID `json:"id"` - URL *url.URL `json:"url"` - Method HTTPMethod `json:"method"` - Proto HTTPProtocol `json:"proto"` - Headers []HTTPHeaderInput `json:"headers"` - Body *string `json:"body"` - ModifyResponse *bool `json:"modifyResponse"` -} - -type ModifyRequestResult struct { - Success bool `json:"success"` -} - -type ModifyResponseInput struct { - RequestID ulid.ULID `json:"requestID"` - Proto HTTPProtocol `json:"proto"` - Headers []HTTPHeaderInput `json:"headers"` - Body *string `json:"body"` - StatusCode int `json:"statusCode"` - StatusReason string `json:"statusReason"` -} - -type ModifyResponseResult struct { - Success bool `json:"success"` -} - -type Project struct { - ID ulid.ULID `json:"id"` - Name string `json:"name"` - IsActive bool `json:"isActive"` - Settings *ProjectSettings `json:"settings"` -} - -type ProjectSettings struct { - Intercept *InterceptSettings `json:"intercept"` -} - -type ScopeHeader struct { - Key *string `json:"key"` - Value *string `json:"value"` -} - -type ScopeHeaderInput struct { - Key *string `json:"key"` - Value *string `json:"value"` -} - -type ScopeRule struct { - URL *string `json:"url"` - Header *ScopeHeader `json:"header"` - Body *string `json:"body"` -} - -type ScopeRuleInput struct { - URL *string `json:"url"` - Header *ScopeHeaderInput `json:"header"` - Body *string `json:"body"` -} - -type SenderRequest struct { - ID ulid.ULID `json:"id"` - SourceRequestLogID *ulid.ULID `json:"sourceRequestLogID"` - URL *url.URL `json:"url"` - Method HTTPMethod `json:"method"` - Proto HTTPProtocol `json:"proto"` - Headers []HTTPHeader `json:"headers"` - Body *string `json:"body"` - Timestamp time.Time `json:"timestamp"` - Response *HTTPResponseLog `json:"response"` -} - -type SenderRequestFilter struct { - OnlyInScope bool `json:"onlyInScope"` - SearchExpression *string `json:"searchExpression"` -} - -type SenderRequestFilterInput struct { - OnlyInScope *bool `json:"onlyInScope"` - SearchExpression *string `json:"searchExpression"` -} - -type SenderRequestInput struct { - ID *ulid.ULID `json:"id"` - URL *url.URL `json:"url"` - Method *HTTPMethod `json:"method"` - Proto *HTTPProtocol `json:"proto"` - Headers []HTTPHeaderInput `json:"headers"` - Body *string `json:"body"` -} - -type UpdateInterceptSettingsInput struct { - RequestsEnabled bool `json:"requestsEnabled"` - ResponsesEnabled bool `json:"responsesEnabled"` - RequestFilter *string `json:"requestFilter"` - ResponseFilter *string `json:"responseFilter"` -} - -type HTTPMethod string - -const ( - HTTPMethodGet HTTPMethod = "GET" - HTTPMethodHead HTTPMethod = "HEAD" - HTTPMethodPost HTTPMethod = "POST" - HTTPMethodPut HTTPMethod = "PUT" - HTTPMethodDelete HTTPMethod = "DELETE" - HTTPMethodConnect HTTPMethod = "CONNECT" - HTTPMethodOptions HTTPMethod = "OPTIONS" - HTTPMethodTrace HTTPMethod = "TRACE" - HTTPMethodPatch HTTPMethod = "PATCH" -) - -var AllHTTPMethod = []HTTPMethod{ - HTTPMethodGet, - HTTPMethodHead, - HTTPMethodPost, - HTTPMethodPut, - HTTPMethodDelete, - HTTPMethodConnect, - HTTPMethodOptions, - HTTPMethodTrace, - HTTPMethodPatch, -} - -func (e HTTPMethod) IsValid() bool { - switch e { - case HTTPMethodGet, HTTPMethodHead, HTTPMethodPost, HTTPMethodPut, HTTPMethodDelete, HTTPMethodConnect, HTTPMethodOptions, HTTPMethodTrace, HTTPMethodPatch: - return true - } - return false -} - -func (e HTTPMethod) String() string { - return string(e) -} - -func (e *HTTPMethod) UnmarshalGQL(v interface{}) error { - str, ok := v.(string) - if !ok { - return fmt.Errorf("enums must be strings") - } - - *e = HTTPMethod(str) - if !e.IsValid() { - return fmt.Errorf("%s is not a valid HttpMethod", str) - } - return nil -} - -func (e HTTPMethod) MarshalGQL(w io.Writer) { - fmt.Fprint(w, strconv.Quote(e.String())) -} - -type HTTPProtocol string - -const ( - HTTPProtocolHTTP10 HTTPProtocol = "HTTP10" - HTTPProtocolHTTP11 HTTPProtocol = "HTTP11" - HTTPProtocolHTTP20 HTTPProtocol = "HTTP20" -) - -var AllHTTPProtocol = []HTTPProtocol{ - HTTPProtocolHTTP10, - HTTPProtocolHTTP11, - HTTPProtocolHTTP20, -} - -func (e HTTPProtocol) IsValid() bool { - switch e { - case HTTPProtocolHTTP10, HTTPProtocolHTTP11, HTTPProtocolHTTP20: - return true - } - return false -} - -func (e HTTPProtocol) String() string { - return string(e) -} - -func (e *HTTPProtocol) UnmarshalGQL(v interface{}) error { - str, ok := v.(string) - if !ok { - return fmt.Errorf("enums must be strings") - } - - *e = HTTPProtocol(str) - if !e.IsValid() { - return fmt.Errorf("%s is not a valid HttpProtocol", str) - } - return nil -} - -func (e HTTPProtocol) MarshalGQL(w io.Writer) { - fmt.Fprint(w, strconv.Quote(e.String())) -} diff --git a/pkg/api/resolvers.go b/pkg/api/resolvers.go deleted file mode 100644 index 1727125..0000000 --- a/pkg/api/resolvers.go +++ /dev/null @@ -1,1005 +0,0 @@ -package api - -//go:generate go run github.com/99designs/gqlgen - -import ( - "bytes" - "context" - "errors" - "fmt" - "io" - "io/ioutil" - "net/http" - "regexp" - "sort" - "strings" - - "github.com/99designs/gqlgen/graphql" - "github.com/oklog/ulid" - "github.com/vektah/gqlparser/v2/gqlerror" - - "github.com/dstotijn/hetty/pkg/filter" - "github.com/dstotijn/hetty/pkg/proj" - "github.com/dstotijn/hetty/pkg/proxy" - "github.com/dstotijn/hetty/pkg/proxy/intercept" - "github.com/dstotijn/hetty/pkg/reqlog" - "github.com/dstotijn/hetty/pkg/scope" - "github.com/dstotijn/hetty/pkg/sender" -) - -var httpProtocolMap = map[string]HTTPProtocol{ - sender.HTTPProto10: HTTPProtocolHTTP10, - sender.HTTPProto11: HTTPProtocolHTTP11, - sender.HTTPProto20: HTTPProtocolHTTP20, -} - -var revHTTPProtocolMap = map[HTTPProtocol]string{ - HTTPProtocolHTTP10: sender.HTTPProto10, - HTTPProtocolHTTP11: sender.HTTPProto11, - HTTPProtocolHTTP20: sender.HTTPProto20, -} - -type Resolver struct { - ProjectService *proj.Service - RequestLogService *reqlog.Service - InterceptService *intercept.Service - SenderService *sender.Service -} - -type ( - queryResolver struct{ *Resolver } - mutationResolver struct{ *Resolver } -) - -func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } -func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } - -func (r *queryResolver) HTTPRequestLogs(ctx context.Context) ([]HTTPRequestLog, error) { - reqs, err := r.RequestLogService.FindRequests(ctx) - if errors.Is(err, proj.ErrNoProject) { - return nil, noActiveProjectErr(ctx) - } else if err != nil { - return nil, fmt.Errorf("could not query repository for requests: %w", err) - } - - logs := make([]HTTPRequestLog, len(reqs)) - - for i, req := range reqs { - req, err := parseRequestLog(req) - if err != nil { - return nil, err - } - - logs[i] = req - } - - return logs, nil -} - -func (r *queryResolver) HTTPRequestLog(ctx context.Context, id ulid.ULID) (*HTTPRequestLog, error) { - log, err := r.RequestLogService.FindRequestLogByID(ctx, id) - if errors.Is(err, reqlog.ErrRequestNotFound) { - return nil, nil - } else if err != nil { - return nil, fmt.Errorf("could not get request by ID: %w", err) - } - - req, err := parseRequestLog(log) - if err != nil { - return nil, err - } - - return &req, nil -} - -func parseRequestLog(reqLog reqlog.RequestLog) (HTTPRequestLog, error) { - method := HTTPMethod(reqLog.Method) - if method != "" && !method.IsValid() { - return HTTPRequestLog{}, fmt.Errorf("request has invalid method: %v", method) - } - - log := HTTPRequestLog{ - ID: reqLog.ID, - Proto: reqLog.Proto, - Method: method, - Timestamp: ulid.Time(reqLog.ID.Time()), - } - - if reqLog.URL != nil { - log.URL = reqLog.URL.String() - } - - if len(reqLog.Body) > 0 { - bodyStr := string(reqLog.Body) - log.Body = &bodyStr - } - - if reqLog.Header != nil { - log.Headers = make([]HTTPHeader, 0) - - for key, values := range reqLog.Header { - for _, value := range values { - log.Headers = append(log.Headers, HTTPHeader{ - Key: key, - Value: value, - }) - } - } - - sort.Sort(HTTPHeaders(log.Headers)) - } - - if reqLog.Response != nil { - resLog, err := parseResponseLog(*reqLog.Response) - if err != nil { - return HTTPRequestLog{}, err - } - - resLog.ID = reqLog.ID - - log.Response = &resLog - } - - return log, nil -} - -func parseResponseLog(resLog reqlog.ResponseLog) (HTTPResponseLog, error) { - proto := httpProtocolMap[resLog.Proto] - if !proto.IsValid() { - return HTTPResponseLog{}, fmt.Errorf("sender response has invalid protocol: %v", resLog.Proto) - } - - httpResLog := HTTPResponseLog{ - Proto: proto, - StatusCode: resLog.StatusCode, - } - statusReasonSubs := strings.SplitN(resLog.Status, " ", 2) - - if len(statusReasonSubs) == 2 { - httpResLog.StatusReason = statusReasonSubs[1] - } - - if len(resLog.Body) > 0 { - bodyStr := string(resLog.Body) - httpResLog.Body = &bodyStr - } - - if resLog.Header != nil { - httpResLog.Headers = make([]HTTPHeader, 0) - - for key, values := range resLog.Header { - for _, value := range values { - httpResLog.Headers = append(httpResLog.Headers, HTTPHeader{ - Key: key, - Value: value, - }) - } - } - - sort.Sort(HTTPHeaders(httpResLog.Headers)) - } - - return httpResLog, nil -} - -func (r *mutationResolver) CreateProject(ctx context.Context, name string) (*Project, error) { - p, err := r.ProjectService.CreateProject(ctx, name) - if errors.Is(err, proj.ErrInvalidName) { - return nil, gqlerror.Errorf("Project name must only contain alphanumeric or space chars.") - } else if err != nil { - return nil, fmt.Errorf("could not open project: %w", err) - } - - project := parseProject(r.ProjectService, p) - - return &project, nil -} - -func (r *mutationResolver) OpenProject(ctx context.Context, id ulid.ULID) (*Project, error) { - p, err := r.ProjectService.OpenProject(ctx, id) - if errors.Is(err, proj.ErrInvalidName) { - return nil, gqlerror.Errorf("Project name must only contain alphanumeric or space chars.") - } else if err != nil { - return nil, fmt.Errorf("could not open project: %w", err) - } - - project := parseProject(r.ProjectService, p) - - return &project, nil -} - -func (r *queryResolver) ActiveProject(ctx context.Context) (*Project, error) { - p, err := r.ProjectService.ActiveProject(ctx) - if errors.Is(err, proj.ErrNoProject) { - return nil, nil - } else if err != nil { - return nil, fmt.Errorf("could not open project: %w", err) - } - - project := parseProject(r.ProjectService, p) - - return &project, nil -} - -func (r *queryResolver) Projects(ctx context.Context) ([]Project, error) { - p, err := r.ProjectService.Projects(ctx) - if err != nil { - return nil, fmt.Errorf("could not get projects: %w", err) - } - - projects := make([]Project, len(p)) - for i, proj := range p { - projects[i] = parseProject(r.ProjectService, proj) - } - - return projects, nil -} - -func (r *queryResolver) Scope(ctx context.Context) ([]ScopeRule, error) { - rules := r.ProjectService.Scope().Rules() - return scopeToScopeRules(rules), nil -} - -func regexpToStringPtr(r *regexp.Regexp) *string { - if r == nil { - return nil - } - - s := r.String() - - return &s -} - -func (r *mutationResolver) CloseProject(ctx context.Context) (*CloseProjectResult, error) { - if err := r.ProjectService.CloseProject(); err != nil { - return nil, fmt.Errorf("could not close project: %w", err) - } - - return &CloseProjectResult{true}, nil -} - -func (r *mutationResolver) DeleteProject(ctx context.Context, id ulid.ULID) (*DeleteProjectResult, error) { - if err := r.ProjectService.DeleteProject(ctx, id); err != nil { - return nil, fmt.Errorf("could not delete project: %w", err) - } - - return &DeleteProjectResult{ - Success: true, - }, nil -} - -func (r *mutationResolver) ClearHTTPRequestLog(ctx context.Context) (*ClearHTTPRequestLogResult, error) { - project, err := r.ProjectService.ActiveProject(ctx) - if errors.Is(err, proj.ErrNoProject) { - return nil, noActiveProjectErr(ctx) - } else if err != nil { - return nil, fmt.Errorf("could not get active project: %w", err) - } - - if err := r.RequestLogService.ClearRequests(ctx, project.ID); err != nil { - return nil, fmt.Errorf("could not clear request log: %w", err) - } - - return &ClearHTTPRequestLogResult{true}, nil -} - -func (r *mutationResolver) SetScope(ctx context.Context, input []ScopeRuleInput) ([]ScopeRule, error) { - rules := make([]scope.Rule, len(input)) - - for i, rule := range input { - u, err := stringPtrToRegexp(rule.URL) - if err != nil { - return nil, fmt.Errorf("invalid URL in scope rule: %w", err) - } - - var headerKey, headerValue *regexp.Regexp - - if rule.Header != nil { - headerKey, err = stringPtrToRegexp(rule.Header.Key) - if err != nil { - return nil, fmt.Errorf("invalid header key in scope rule: %w", err) - } - - headerValue, err = stringPtrToRegexp(rule.Header.Key) - if err != nil { - return nil, fmt.Errorf("invalid header value in scope rule: %w", err) - } - } - - body, err := stringPtrToRegexp(rule.Body) - if err != nil { - return nil, fmt.Errorf("invalid body in scope rule: %w", err) - } - - rules[i] = scope.Rule{ - URL: u, - Header: scope.Header{ - Key: headerKey, - Value: headerValue, - }, - Body: body, - } - } - - err := r.ProjectService.SetScopeRules(ctx, rules) - if err != nil { - return nil, fmt.Errorf("could not set scope rules: %w", err) - } - - return scopeToScopeRules(rules), nil -} - -func (r *queryResolver) HTTPRequestLogFilter(ctx context.Context) (*HTTPRequestLogFilter, error) { - return findReqFilterToHTTPReqLogFilter(r.RequestLogService.FindReqsFilter()), nil -} - -func (r *mutationResolver) SetHTTPRequestLogFilter( - ctx context.Context, - input *HTTPRequestLogFilterInput, -) (*HTTPRequestLogFilter, error) { - filter, err := findRequestsFilterFromInput(input) - if err != nil { - return nil, fmt.Errorf("could not parse request log filter: %w", err) - } - - err = r.ProjectService.SetRequestLogFindFilter(ctx, filter) - if errors.Is(err, proj.ErrNoProject) { - return nil, noActiveProjectErr(ctx) - } else if err != nil { - return nil, fmt.Errorf("could not set request log filter: %w", err) - } - - return findReqFilterToHTTPReqLogFilter(filter), nil -} - -func (r *queryResolver) SenderRequest(ctx context.Context, id ulid.ULID) (*SenderRequest, error) { - senderReq, err := r.SenderService.FindRequestByID(ctx, id) - if errors.Is(err, sender.ErrRequestNotFound) { - return nil, nil - } else if err != nil { - return nil, fmt.Errorf("could not get request by ID: %w", err) - } - - req, err := parseSenderRequest(senderReq) - if err != nil { - return nil, err - } - - return &req, nil -} - -func (r *queryResolver) SenderRequests(ctx context.Context) ([]SenderRequest, error) { - reqs, err := r.SenderService.FindRequests(ctx) - if errors.Is(err, proj.ErrNoProject) { - return nil, noActiveProjectErr(ctx) - } else if err != nil { - return nil, fmt.Errorf("failed to find sender requests: %w", err) - } - - senderReqs := make([]SenderRequest, len(reqs)) - - for i, req := range reqs { - req, err := parseSenderRequest(req) - if err != nil { - return nil, err - } - - senderReqs[i] = req - } - - return senderReqs, nil -} - -func (r *mutationResolver) SetSenderRequestFilter( - ctx context.Context, - input *SenderRequestFilterInput, -) (*SenderRequestFilter, error) { - filter, err := findSenderRequestsFilterFromInput(input) - if err != nil { - return nil, fmt.Errorf("could not parse request log filter: %w", err) - } - - err = r.ProjectService.SetSenderRequestFindFilter(ctx, filter) - if errors.Is(err, proj.ErrNoProject) { - return nil, noActiveProjectErr(ctx) - } else if err != nil { - return nil, fmt.Errorf("could not set request log filter: %w", err) - } - - return findReqFilterToSenderReqFilter(filter), nil -} - -func (r *mutationResolver) CreateOrUpdateSenderRequest( - ctx context.Context, - input SenderRequestInput, -) (*SenderRequest, error) { - req := sender.Request{ - URL: input.URL, - Header: make(http.Header), - } - - if input.ID != nil { - req.ID = *input.ID - } - - if input.Method != nil { - req.Method = input.Method.String() - } - - if input.Proto != nil { - req.Proto = revHTTPProtocolMap[*input.Proto] - } - - for _, header := range input.Headers { - req.Header.Add(header.Key, header.Value) - } - - if input.Body != nil { - req.Body = []byte(*input.Body) - } - - req, err := r.SenderService.CreateOrUpdateRequest(ctx, req) - if errors.Is(err, proj.ErrNoProject) { - return nil, noActiveProjectErr(ctx) - } else if err != nil { - return nil, fmt.Errorf("could not create sender request: %w", err) - } - - senderReq, err := parseSenderRequest(req) - if err != nil { - return nil, err - } - - return &senderReq, nil -} - -func (r *mutationResolver) CreateSenderRequestFromHTTPRequestLog( - ctx context.Context, - id ulid.ULID, -) (*SenderRequest, error) { - req, err := r.SenderService.CloneFromRequestLog(ctx, id) - if errors.Is(err, proj.ErrNoProject) { - return nil, noActiveProjectErr(ctx) - } else if err != nil { - return nil, fmt.Errorf("could not create sender request from http request log: %w", err) - } - - senderReq, err := parseSenderRequest(req) - if err != nil { - return nil, err - } - - return &senderReq, nil -} - -func (r *mutationResolver) SendRequest(ctx context.Context, id ulid.ULID) (*SenderRequest, error) { - // Use new context, because we don't want to risk interrupting sending the request - // or the subsequent storing of the response, e.g. if ctx gets cancelled or - // times out. - ctx2 := context.Background() - - var sendErr *sender.SendError - - //nolint:contextcheck - req, err := r.SenderService.SendRequest(ctx2, id) - - switch { - case errors.Is(err, proj.ErrNoProject): - return nil, noActiveProjectErr(ctx) - case errors.As(err, &sendErr): - return nil, &gqlerror.Error{ - Path: graphql.GetPath(ctx), - Message: fmt.Sprintf("Sending request failed: %v", sendErr.Unwrap()), - Extensions: map[string]interface{}{ - "code": "send_request_failed", - }, - } - case err != nil: - return nil, fmt.Errorf("could not send request: %w", err) - } - - senderReq, err := parseSenderRequest(req) - if err != nil { - return nil, err - } - - return &senderReq, nil -} - -func (r *mutationResolver) DeleteSenderRequests(ctx context.Context) (*DeleteSenderRequestsResult, error) { - project, err := r.ProjectService.ActiveProject(ctx) - if errors.Is(err, proj.ErrNoProject) { - return nil, noActiveProjectErr(ctx) - } else if err != nil { - return nil, fmt.Errorf("could not get active project: %w", err) - } - - if err := r.SenderService.DeleteRequests(ctx, project.ID); err != nil { - return nil, fmt.Errorf("could not clear request log: %w", err) - } - - return &DeleteSenderRequestsResult{true}, nil -} - -func (r *queryResolver) InterceptedRequests(ctx context.Context) (httpReqs []HTTPRequest, err error) { - items := r.InterceptService.Items() - - for _, item := range items { - req, err := parseInterceptItem(item) - if err != nil { - return nil, err - } - - httpReqs = append(httpReqs, req) - } - - return httpReqs, nil -} - -func (r *queryResolver) InterceptedRequest(ctx context.Context, id ulid.ULID) (*HTTPRequest, error) { - item, err := r.InterceptService.ItemByID(id) - if errors.Is(err, intercept.ErrRequestNotFound) { - return nil, nil - } else if err != nil { - return nil, fmt.Errorf("could not get request by ID: %w", err) - } - - req, err := parseInterceptItem(item) - if err != nil { - return nil, err - } - - return &req, nil -} - -func (r *mutationResolver) ModifyRequest(ctx context.Context, input ModifyRequestInput) (*ModifyRequestResult, error) { - body := "" - if input.Body != nil { - body = *input.Body - } - - //nolint:noctx - req, err := http.NewRequest(input.Method.String(), input.URL.String(), strings.NewReader(body)) - if err != nil { - return nil, fmt.Errorf("failed to construct HTTP request: %w", err) - } - - for _, header := range input.Headers { - req.Header.Add(header.Key, header.Value) - } - - err = r.InterceptService.ModifyRequest(input.ID, req, input.ModifyResponse) - if err != nil { - return nil, fmt.Errorf("could not modify http request: %w", err) - } - - return &ModifyRequestResult{Success: true}, nil -} - -func (r *mutationResolver) CancelRequest(ctx context.Context, id ulid.ULID) (*CancelRequestResult, error) { - err := r.InterceptService.CancelRequest(id) - if err != nil { - return nil, fmt.Errorf("could not cancel http request: %w", err) - } - - return &CancelRequestResult{Success: true}, nil -} - -func (r *mutationResolver) ModifyResponse( - ctx context.Context, - input ModifyResponseInput, -) (*ModifyResponseResult, error) { - res := &http.Response{ - Header: make(http.Header), - Status: fmt.Sprintf("%v %v", input.StatusCode, input.StatusReason), - StatusCode: input.StatusCode, - Proto: revHTTPProtocolMap[input.Proto], - } - - var ok bool - if res.ProtoMajor, res.ProtoMinor, ok = http.ParseHTTPVersion(res.Proto); !ok { - return nil, fmt.Errorf("malformed HTTP version: %q", res.Proto) - } - - var body string - if input.Body != nil { - body = *input.Body - } - - res.Body = io.NopCloser(strings.NewReader(body)) - - for _, header := range input.Headers { - res.Header.Add(header.Key, header.Value) - } - - err := r.InterceptService.ModifyResponse(input.RequestID, res) - if err != nil { - return nil, fmt.Errorf("could not modify http request: %w", err) - } - - return &ModifyResponseResult{Success: true}, nil -} - -func (r *mutationResolver) CancelResponse(ctx context.Context, requestID ulid.ULID) (*CancelResponseResult, error) { - err := r.InterceptService.CancelResponse(requestID) - if err != nil { - return nil, fmt.Errorf("could not cancel http response: %w", err) - } - - return &CancelResponseResult{Success: true}, nil -} - -func (r *mutationResolver) UpdateInterceptSettings( - ctx context.Context, - input UpdateInterceptSettingsInput, -) (*InterceptSettings, error) { - settings := intercept.Settings{ - RequestsEnabled: input.RequestsEnabled, - ResponsesEnabled: input.ResponsesEnabled, - } - - if input.RequestFilter != nil && *input.RequestFilter != "" { - expr, err := filter.ParseQuery(*input.RequestFilter) - if err != nil { - return nil, fmt.Errorf("could not parse request filter: %w", err) - } - - settings.RequestFilter = expr - } - - if input.ResponseFilter != nil && *input.ResponseFilter != "" { - expr, err := filter.ParseQuery(*input.ResponseFilter) - if err != nil { - return nil, fmt.Errorf("could not parse response filter: %w", err) - } - - settings.ResponseFilter = expr - } - - err := r.ProjectService.UpdateInterceptSettings(ctx, settings) - if errors.Is(err, proj.ErrNoProject) { - return nil, noActiveProjectErr(ctx) - } else if err != nil { - return nil, fmt.Errorf("could not update intercept settings: %w", err) - } - - updated := &InterceptSettings{ - RequestsEnabled: settings.RequestsEnabled, - ResponsesEnabled: settings.ResponsesEnabled, - } - - if settings.RequestFilter != nil { - reqFilter := settings.RequestFilter.String() - updated.RequestFilter = &reqFilter - } - - if settings.ResponseFilter != nil { - resFilter := settings.ResponseFilter.String() - updated.ResponseFilter = &resFilter - } - - return updated, nil -} - -func parseSenderRequest(req sender.Request) (SenderRequest, error) { - method := HTTPMethod(req.Method) - if method != "" && !method.IsValid() { - return SenderRequest{}, fmt.Errorf("sender request has invalid method: %v", method) - } - - reqProto := httpProtocolMap[req.Proto] - if !reqProto.IsValid() { - return SenderRequest{}, fmt.Errorf("sender request has invalid protocol: %v", req.Proto) - } - - senderReq := SenderRequest{ - ID: req.ID, - URL: req.URL, - Method: method, - Proto: HTTPProtocol(req.Proto), - Timestamp: ulid.Time(req.ID.Time()), - } - - if req.SourceRequestLogID.Compare(ulid.ULID{}) != 0 { - senderReq.SourceRequestLogID = &req.SourceRequestLogID - } - - if req.Header != nil { - senderReq.Headers = make([]HTTPHeader, 0) - - for key, values := range req.Header { - for _, value := range values { - senderReq.Headers = append(senderReq.Headers, HTTPHeader{ - Key: key, - Value: value, - }) - } - } - - sort.Sort(HTTPHeaders(senderReq.Headers)) - } - - if len(req.Body) > 0 { - bodyStr := string(req.Body) - senderReq.Body = &bodyStr - } - - if req.Response != nil { - resLog, err := parseResponseLog(*req.Response) - if err != nil { - return SenderRequest{}, err - } - - resLog.ID = req.ID - - senderReq.Response = &resLog - } - - return senderReq, nil -} - -func parseHTTPRequest(req *http.Request) (HTTPRequest, error) { - method := HTTPMethod(req.Method) - if method != "" && !method.IsValid() { - return HTTPRequest{}, fmt.Errorf("http request has invalid method: %v", method) - } - - reqProto := httpProtocolMap[req.Proto] - if !reqProto.IsValid() { - return HTTPRequest{}, fmt.Errorf("http request has invalid protocol: %v", req.Proto) - } - - id, ok := proxy.RequestIDFromContext(req.Context()) - if !ok { - return HTTPRequest{}, errors.New("http request has missing ID") - } - - httpReq := HTTPRequest{ - ID: id, - URL: req.URL, - Method: method, - Proto: HTTPProtocol(req.Proto), - } - - if req.Header != nil { - httpReq.Headers = make([]HTTPHeader, 0) - - for key, values := range req.Header { - for _, value := range values { - httpReq.Headers = append(httpReq.Headers, HTTPHeader{ - Key: key, - Value: value, - }) - } - } - - sort.Sort(HTTPHeaders(httpReq.Headers)) - } - - if req.Body != nil { - body, err := ioutil.ReadAll(req.Body) - if err != nil { - return HTTPRequest{}, fmt.Errorf("failed to read request body: %w", err) - } - - req.Body = ioutil.NopCloser(bytes.NewBuffer(body)) - bodyStr := string(body) - httpReq.Body = &bodyStr - } - - return httpReq, nil -} - -func parseHTTPResponse(res *http.Response) (HTTPResponse, error) { - resProto := httpProtocolMap[res.Proto] - if !resProto.IsValid() { - return HTTPResponse{}, fmt.Errorf("http response has invalid protocol: %v", res.Proto) - } - - id, ok := proxy.RequestIDFromContext(res.Request.Context()) - if !ok { - return HTTPResponse{}, errors.New("http response has missing ID") - } - - httpRes := HTTPResponse{ - ID: id, - Proto: resProto, - StatusCode: res.StatusCode, - } - - statusReasonSubs := strings.SplitN(res.Status, " ", 2) - - if len(statusReasonSubs) == 2 { - httpRes.StatusReason = statusReasonSubs[1] - } - - if res.Header != nil { - httpRes.Headers = make([]HTTPHeader, 0) - - for key, values := range res.Header { - for _, value := range values { - httpRes.Headers = append(httpRes.Headers, HTTPHeader{ - Key: key, - Value: value, - }) - } - } - - sort.Sort(HTTPHeaders(httpRes.Headers)) - } - - if res.Body != nil { - body, err := ioutil.ReadAll(res.Body) - if err != nil { - return HTTPResponse{}, fmt.Errorf("failed to read response body: %w", err) - } - - res.Body = ioutil.NopCloser(bytes.NewBuffer(body)) - bodyStr := string(body) - httpRes.Body = &bodyStr - } - - return httpRes, nil -} - -func parseInterceptItem(item intercept.Item) (req HTTPRequest, err error) { - if item.Response != nil { - req, err = parseHTTPRequest(item.Response.Request) - if err != nil { - return HTTPRequest{}, err - } - - res, err := parseHTTPResponse(item.Response) - if err != nil { - return HTTPRequest{}, err - } - - req.Response = &res - } else if item.Request != nil { - req, err = parseHTTPRequest(item.Request) - if err != nil { - return HTTPRequest{}, err - } - } - - return req, nil -} - -func parseProject(projSvc *proj.Service, p proj.Project) Project { - project := Project{ - ID: p.ID, - Name: p.Name, - IsActive: projSvc.IsProjectActive(p.ID), - Settings: &ProjectSettings{ - Intercept: &InterceptSettings{ - RequestsEnabled: p.Settings.InterceptRequests, - ResponsesEnabled: p.Settings.InterceptResponses, - }, - }, - } - - if p.Settings.InterceptRequestFilter != nil { - interceptReqFilter := p.Settings.InterceptRequestFilter.String() - project.Settings.Intercept.RequestFilter = &interceptReqFilter - } - - if p.Settings.InterceptResponseFilter != nil { - interceptResFilter := p.Settings.InterceptResponseFilter.String() - project.Settings.Intercept.ResponseFilter = &interceptResFilter - } - - return project -} - -func stringPtrToRegexp(s *string) (*regexp.Regexp, error) { - if s == nil { - return nil, nil - } - - return regexp.Compile(*s) -} - -func scopeToScopeRules(rules []scope.Rule) []ScopeRule { - scopeRules := make([]ScopeRule, len(rules)) - for i, rule := range rules { - scopeRules[i].URL = regexpToStringPtr(rule.URL) - if rule.Header.Key != nil || rule.Header.Value != nil { - scopeRules[i].Header = &ScopeHeader{ - Key: regexpToStringPtr(rule.Header.Key), - Value: regexpToStringPtr(rule.Header.Value), - } - } - - scopeRules[i].Body = regexpToStringPtr(rule.Body) - } - - return scopeRules -} - -func findRequestsFilterFromInput(input *HTTPRequestLogFilterInput) (findFilter reqlog.FindRequestsFilter, err error) { - if input == nil { - return - } - - if input.OnlyInScope != nil { - findFilter.OnlyInScope = *input.OnlyInScope - } - - if input.SearchExpression != nil && *input.SearchExpression != "" { - expr, err := filter.ParseQuery(*input.SearchExpression) - if err != nil { - return reqlog.FindRequestsFilter{}, fmt.Errorf("could not parse search query: %w", err) - } - - findFilter.SearchExpr = expr - } - - return -} - -func findSenderRequestsFilterFromInput(input *SenderRequestFilterInput) (findFilter sender.FindRequestsFilter, err error) { - if input == nil { - return - } - - if input.OnlyInScope != nil { - findFilter.OnlyInScope = *input.OnlyInScope - } - - if input.SearchExpression != nil && *input.SearchExpression != "" { - expr, err := filter.ParseQuery(*input.SearchExpression) - if err != nil { - return sender.FindRequestsFilter{}, fmt.Errorf("could not parse search query: %w", err) - } - - findFilter.SearchExpr = expr - } - - return -} - -func findReqFilterToHTTPReqLogFilter(findReqFilter reqlog.FindRequestsFilter) *HTTPRequestLogFilter { - empty := reqlog.FindRequestsFilter{} - if findReqFilter == empty { - return nil - } - - httpReqLogFilter := &HTTPRequestLogFilter{ - OnlyInScope: findReqFilter.OnlyInScope, - } - - if findReqFilter.SearchExpr != nil { - searchExpr := findReqFilter.SearchExpr.String() - httpReqLogFilter.SearchExpression = &searchExpr - } - - return httpReqLogFilter -} - -func findReqFilterToSenderReqFilter(findReqFilter sender.FindRequestsFilter) *SenderRequestFilter { - empty := sender.FindRequestsFilter{} - if findReqFilter == empty { - return nil - } - - senderReqFilter := &SenderRequestFilter{ - OnlyInScope: findReqFilter.OnlyInScope, - } - - if findReqFilter.SearchExpr != nil { - searchExpr := findReqFilter.SearchExpr.String() - senderReqFilter.SearchExpression = &searchExpr - } - - return senderReqFilter -} - -func noActiveProjectErr(ctx context.Context) error { - return &gqlerror.Error{ - Path: graphql.GetPath(ctx), - Message: "No active project.", - Extensions: map[string]interface{}{ - "code": "no_active_project", - }, - } -} diff --git a/pkg/db/bolt/proj.go b/pkg/db/bolt/proj.go index 4ac7c05..42f5aad 100644 --- a/pkg/db/bolt/proj.go +++ b/pkg/db/bolt/proj.go @@ -1,14 +1,12 @@ package bolt import ( - "bytes" "context" - "encoding/gob" "errors" "fmt" - "github.com/oklog/ulid" bolt "go.etcd.io/bbolt" + "google.golang.org/protobuf/proto" "github.com/dstotijn/hetty/pkg/proj" ) @@ -32,13 +30,13 @@ func projectsBucket(tx *bolt.Tx) (*bolt.Bucket, error) { return b, nil } -func projectBucket(tx *bolt.Tx, projectID []byte) (*bolt.Bucket, error) { +func projectBucket(tx *bolt.Tx, projectID string) (*bolt.Bucket, error) { pb, err := projectsBucket(tx) if err != nil { return nil, err } - b := pb.Bucket(projectID[:]) + b := pb.Bucket([]byte(projectID)) if b == nil { return nil, ErrProjectBucketNotFound } @@ -46,21 +44,19 @@ func projectBucket(tx *bolt.Tx, projectID []byte) (*bolt.Bucket, error) { return b, nil } -func (db *Database) UpsertProject(ctx context.Context, project proj.Project) error { - buf := bytes.Buffer{} - - err := gob.NewEncoder(&buf).Encode(project) - if err != nil { - return fmt.Errorf("bolt: failed to encode project: %w", err) - } - - err = db.bolt.Update(func(tx *bolt.Tx) error { - b, err := createNestedBucket(tx, projectsBucketName, project.ID[:]) +func (db *Database) UpsertProject(ctx context.Context, project *proj.Project) error { + err := db.bolt.Update(func(tx *bolt.Tx) error { + b, err := createNestedBucket(tx, projectsBucketName, []byte(project.Id)) if err != nil { return fmt.Errorf("bolt: failed to create project bucket: %w", err) } - err = b.Put(projectKey, buf.Bytes()) + buf, err := proto.Marshal(project) + if err != nil { + return fmt.Errorf("bolt: failed to marshal project: %w", err) + } + + err = b.Put(projectKey, buf) if err != nil { return fmt.Errorf("bolt: failed to upsert project: %w", err) } @@ -84,9 +80,11 @@ func (db *Database) UpsertProject(ctx context.Context, project proj.Project) err return nil } -func (db *Database) FindProjectByID(ctx context.Context, projectID ulid.ULID) (project proj.Project, err error) { - err = db.bolt.View(func(tx *bolt.Tx) error { - bucket, err := projectBucket(tx, projectID[:]) +func (db *Database) FindProjectByID(ctx context.Context, projectID string) (*proj.Project, error) { + project := &proj.Project{} + + err := db.bolt.View(func(tx *bolt.Tx) error { + bucket, err := projectBucket(tx, projectID) if errors.Is(err, ErrProjectsBucketNotFound) || errors.Is(err, ErrProjectBucketNotFound) { return proj.ErrProjectNotFound } @@ -99,28 +97,28 @@ func (db *Database) FindProjectByID(ctx context.Context, projectID ulid.ULID) (p return proj.ErrProjectNotFound } - err = gob.NewDecoder(bytes.NewReader(rawProject)).Decode(&project) + err = proto.Unmarshal(rawProject, project) if err != nil { - return fmt.Errorf("failed to decode project: %w", err) + return fmt.Errorf("failed to unmarshal project: %w", err) } return nil }) if err != nil { - return proj.Project{}, fmt.Errorf("bolt: failed to commit transaction: %w", err) + return nil, fmt.Errorf("bolt: failed to commit transaction: %w", err) } return project, nil } -func (db *Database) DeleteProject(ctx context.Context, projectID ulid.ULID) error { +func (db *Database) DeleteProject(ctx context.Context, projectID string) error { err := db.bolt.Update(func(tx *bolt.Tx) error { pb, err := projectsBucket(tx) if err != nil { return err } - err = pb.DeleteBucket(projectID[:]) + err = pb.DeleteBucket([]byte(projectID)) if err != nil { return fmt.Errorf("failed to delete project bucket: %w", err) } @@ -134,8 +132,8 @@ func (db *Database) DeleteProject(ctx context.Context, projectID ulid.ULID) erro return nil } -func (db *Database) Projects(ctx context.Context) ([]proj.Project, error) { - projects := make([]proj.Project, 0) +func (db *Database) Projects(ctx context.Context) ([]*proj.Project, error) { + projects := make([]*proj.Project, 0) err := db.bolt.View(func(tx *bolt.Tx) error { pb, err := projectsBucket(tx) @@ -144,7 +142,7 @@ func (db *Database) Projects(ctx context.Context) ([]proj.Project, error) { } err = pb.ForEachBucket(func(projectID []byte) error { - bucket, err := projectBucket(tx, projectID) + bucket, err := projectBucket(tx, string(projectID)) if err != nil { return err } @@ -154,16 +152,16 @@ func (db *Database) Projects(ctx context.Context) ([]proj.Project, error) { return proj.ErrProjectNotFound } - var project proj.Project - err = gob.NewDecoder(bytes.NewReader(rawProject)).Decode(&project) + project := &proj.Project{} + err = proto.Unmarshal(rawProject, project) if err != nil { - return fmt.Errorf("bolt: failed to decode project: %w", err) + return fmt.Errorf("failed to unmarshal project: %w", err) } projects = append(projects, project) return nil }) if err != nil { - return fmt.Errorf("bolt: failed to iterate over projects: %w", err) + return fmt.Errorf("failed to iterate over projects: %w", err) } return nil diff --git a/pkg/db/bolt/proj_test.go b/pkg/db/bolt/proj_test.go index 2026238..b18071e 100644 --- a/pkg/db/bolt/proj_test.go +++ b/pkg/db/bolt/proj_test.go @@ -1,40 +1,21 @@ package bolt_test import ( - "bytes" "context" - "encoding/gob" "errors" - "math/rand" - "regexp" "testing" - "time" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" - "github.com/oklog/ulid" + "github.com/oklog/ulid/v2" "go.etcd.io/bbolt" + "google.golang.org/protobuf/proto" "github.com/dstotijn/hetty/pkg/db/bolt" - "github.com/dstotijn/hetty/pkg/filter" "github.com/dstotijn/hetty/pkg/proj" + "github.com/dstotijn/hetty/pkg/reqlog" "github.com/dstotijn/hetty/pkg/scope" + "github.com/dstotijn/hetty/pkg/testutil" ) -//nolint:gosec -var ulidEntropy = rand.New(rand.NewSource(time.Now().UnixNano())) - -var regexpCompareOpt = cmp.Comparer(func(x, y *regexp.Regexp) bool { - switch { - case x == nil && y == nil: - return true - case x == nil || y == nil: - return false - default: - return x.String() == y.String() - } -}) - func TestUpsertProject(t *testing.T) { t.Parallel() @@ -50,27 +31,20 @@ func TestUpsertProject(t *testing.T) { } defer db.Close() - searchExpr, err := filter.ParseQuery("foo AND bar OR NOT baz") - if err != nil { - t.Fatalf("unexpected error (expected: nil, got: %v)", err) - } - - exp := proj.Project{ - ID: ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy), - Name: "foobar", - Settings: proj.Settings{ - ReqLogBypassOutOfScope: true, - ReqLogOnlyFindInScope: true, - ReqLogSearchExpr: searchExpr, - ScopeRules: []scope.Rule{ - { - URL: regexp.MustCompile("^https://(.*)example.com(.*)$"), - Header: scope.Header{ - Key: regexp.MustCompile("^X-Foo(.*)$"), - Value: regexp.MustCompile("^foo(.*)$"), - }, - Body: regexp.MustCompile("^foo(.*)"), - }, + exp := &proj.Project{ + Id: "foobar-project-id", + Name: "foobar", + ReqLogBypassOutOfScope: true, + ReqLogFilter: &reqlog.RequestLogsFilter{ + OnlyInScope: true, + SearchExpr: "foo AND bar OR NOT baz", + }, + ScopeRules: []*scope.ScopeRule{ + { + UrlRegexp: "^https://(.*)example.com(.*)$", + HeaderKeyRegexp: "^X-Foo(.*)$", + HeaderValueRegexp: "^foo(.*)$", + BodyRegexp: "^foo(.*)", }, }, } @@ -83,7 +57,7 @@ func TestUpsertProject(t *testing.T) { var rawProject []byte err = boltDB.View(func(tx *bbolt.Tx) error { - rawProject = tx.Bucket([]byte("projects")).Bucket(exp.ID[:]).Get([]byte("project")) + rawProject = tx.Bucket([]byte("projects")).Bucket([]byte(exp.Id)).Get([]byte("project")) return nil }) if err != nil { @@ -93,16 +67,14 @@ func TestUpsertProject(t *testing.T) { t.Fatalf("expected raw project to be retrieved, got: nil") } - got := proj.Project{} + got := &proj.Project{} - err = gob.NewDecoder(bytes.NewReader(rawProject)).Decode(&got) + err = proto.Unmarshal(rawProject, got) if err != nil { t.Fatalf("unexpected error decoding project: %v", err) } - if diff := cmp.Diff(exp, got, regexpCompareOpt, cmpopts.IgnoreUnexported(proj.Project{})); diff != "" { - t.Fatalf("project not equal (-exp, +got):\n%v", diff) - } + testutil.ProtoDiff(t, "project not equal", exp, got, "id") } func TestFindProjectByID(t *testing.T) { @@ -123,36 +95,32 @@ func TestFindProjectByID(t *testing.T) { } defer db.Close() - exp := proj.Project{ - ID: ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy), + exp := &proj.Project{ + Id: ulid.Make().String(), } - buf := bytes.Buffer{} - - err = gob.NewEncoder(&buf).Encode(exp) + buf, err := proto.Marshal(exp) if err != nil { t.Fatalf("unexpected error encoding project: %v", err) } err = boltDB.Update(func(tx *bbolt.Tx) error { - b, err := tx.Bucket([]byte("projects")).CreateBucket(exp.ID[:]) + b, err := tx.Bucket([]byte("projects")).CreateBucket([]byte(exp.Id)) if err != nil { return err } - return b.Put([]byte("project"), buf.Bytes()) + return b.Put([]byte("project"), buf) }) if err != nil { t.Fatalf("unexpected error setting project: %v", err) } - got, err := db.FindProjectByID(context.Background(), exp.ID) + got, err := db.FindProjectByID(context.Background(), exp.Id) if err != nil { t.Fatalf("unexpected error finding project: %v", err) } - if diff := cmp.Diff(exp, got, cmpopts.IgnoreUnexported(proj.Project{})); diff != "" { - t.Fatalf("project not equal (-exp, +got):\n%v", diff) - } + testutil.ProtoDiff(t, "project not equal", exp, got) }) t.Run("project not found", func(t *testing.T) { @@ -170,7 +138,7 @@ func TestFindProjectByID(t *testing.T) { } defer db.Close() - projectID := ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) + projectID := ulid.Make().String() _, err = db.FindProjectByID(context.Background(), projectID) if !errors.Is(err, proj.ErrProjectNotFound) { @@ -195,9 +163,9 @@ func TestDeleteProject(t *testing.T) { defer db.Close() // Insert test fixture. - projectID := ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) - err = db.UpsertProject(context.Background(), proj.Project{ - ID: projectID, + projectID := ulid.Make().String() + err = db.UpsertProject(context.Background(), &proj.Project{ + Id: projectID, }) if err != nil { t.Fatalf("unexpected error storing project: %v", err) @@ -209,8 +177,8 @@ func TestDeleteProject(t *testing.T) { } var got *bbolt.Bucket - err = boltDB.View(func(tx *bbolt.Tx) error { - got = tx.Bucket([]byte("projects")).Bucket(projectID[:]) + _ = boltDB.View(func(tx *bbolt.Tx) error { + got = tx.Bucket([]byte("projects")).Bucket([]byte(projectID)) return nil }) if got != nil { @@ -233,13 +201,13 @@ func TestProjects(t *testing.T) { } defer db.Close() - exp := []proj.Project{ + exp := []*proj.Project{ { - ID: ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy), + Id: ulid.Make().String(), Name: "one", }, { - ID: ulid.MustNew(ulid.Timestamp(time.Now())+100, ulidEntropy), + Id: ulid.Make().String(), Name: "two", }, } @@ -261,7 +229,5 @@ func TestProjects(t *testing.T) { t.Fatalf("expected %v projects, got: %v", len(exp), len(got)) } - if diff := cmp.Diff(exp, got, cmpopts.IgnoreUnexported(proj.Project{})); diff != "" { - t.Fatalf("projects not equal (-exp, +got):\n%v", diff) - } + testutil.ProtoSlicesDiff(t, "projects not equal", exp, got) } diff --git a/pkg/db/bolt/reqlog.go b/pkg/db/bolt/reqlog.go index ccff14e..2cc18a4 100644 --- a/pkg/db/bolt/reqlog.go +++ b/pkg/db/bolt/reqlog.go @@ -1,25 +1,23 @@ package bolt import ( - "bytes" "context" - "encoding/gob" "errors" "fmt" - "github.com/oklog/ulid" bolt "go.etcd.io/bbolt" + "google.golang.org/protobuf/proto" + "github.com/dstotijn/hetty/pkg/http" "github.com/dstotijn/hetty/pkg/reqlog" - "github.com/dstotijn/hetty/pkg/scope" ) var ErrRequestLogsBucketNotFound = errors.New("bolt: request logs bucket not found") var reqLogsBucketName = []byte("request_logs") -func requestLogsBucket(tx *bolt.Tx, projectID ulid.ULID) (*bolt.Bucket, error) { - pb, err := projectBucket(tx, projectID[:]) +func requestLogsBucket(tx *bolt.Tx, projectID string) (*bolt.Bucket, error) { + pb, err := projectBucket(tx, projectID) if err != nil { return nil, err } @@ -32,47 +30,36 @@ func requestLogsBucket(tx *bolt.Tx, projectID ulid.ULID) (*bolt.Bucket, error) { return b, nil } -func (db *Database) FindRequestLogs(ctx context.Context, filter reqlog.FindRequestsFilter, scope *scope.Scope) (reqLogs []reqlog.RequestLog, err error) { - if filter.ProjectID.Compare(ulid.ULID{}) == 0 { - return nil, reqlog.ErrProjectIDMustBeSet - } - +func (db *Database) FindRequestLogs(ctx context.Context, projectID string, filterFn func(*reqlog.HttpRequestLog) (bool, error)) (reqLogs []*reqlog.HttpRequestLog, err error) { tx, err := db.bolt.Begin(false) if err != nil { return nil, fmt.Errorf("bolt: failed to begin transaction: %w", err) } defer tx.Rollback() - b, err := requestLogsBucket(tx, filter.ProjectID) + b, err := requestLogsBucket(tx, projectID) if err != nil { return nil, fmt.Errorf("bolt: failed to get request logs bucket: %w", err) } err = b.ForEach(func(reqLogID, rawReqLog []byte) error { - var reqLog reqlog.RequestLog - err = gob.NewDecoder(bytes.NewReader(rawReqLog)).Decode(&reqLog) + var reqLog reqlog.HttpRequestLog + err = proto.Unmarshal(rawReqLog, &reqLog) if err != nil { return fmt.Errorf("failed to decode request log: %w", err) } - if filter.OnlyInScope && !reqLog.MatchScope(scope) { - return nil - } - - // Filter by search expression. TODO: Once pagination is introduced, - // this filter logic should be done as items are retrieved. - if filter.SearchExpr != nil { - match, err := reqLog.Matches(filter.SearchExpr) + if filterFn != nil { + match, err := filterFn(&reqLog) if err != nil { - return fmt.Errorf("failed to match search expression for request log (id: %v): %w", reqLogID, err) + return fmt.Errorf("failed to filter request log: %w", err) } - if !match { return nil } } - reqLogs = append(reqLogs, reqLog) + reqLogs = append(reqLogs, &reqLog) return nil }) if err != nil { @@ -87,46 +74,45 @@ func (db *Database) FindRequestLogs(ctx context.Context, filter reqlog.FindReque return reqLogs, nil } -func (db *Database) FindRequestLogByID(ctx context.Context, projectID, reqLogID ulid.ULID) (reqLog reqlog.RequestLog, err error) { - err = db.bolt.View(func(tx *bolt.Tx) error { +func (db *Database) FindRequestLogByID(ctx context.Context, projectID, reqLogID string) (*reqlog.HttpRequestLog, error) { + reqLog := &reqlog.HttpRequestLog{} + err := db.bolt.View(func(tx *bolt.Tx) error { b, err := requestLogsBucket(tx, projectID) if err != nil { return fmt.Errorf("bolt: failed to get request logs bucket: %w", err) } - rawReqLog := b.Get(reqLogID[:]) + rawReqLog := b.Get([]byte(reqLogID)) if rawReqLog == nil { - return reqlog.ErrRequestNotFound + return reqlog.ErrRequestLogNotFound } - err = gob.NewDecoder(bytes.NewReader(rawReqLog)).Decode(&reqLog) + err = proto.Unmarshal(rawReqLog, reqLog) if err != nil { - return fmt.Errorf("failed to decode request log: %w", err) + return fmt.Errorf("failed to unmarshal request log: %w", err) } return nil }) if err != nil { - return reqlog.RequestLog{}, fmt.Errorf("bolt: failed to find request log by ID: %w", err) + return nil, fmt.Errorf("bolt: failed to find request log by ID: %w", err) } return reqLog, nil } -func (db *Database) StoreRequestLog(ctx context.Context, reqLog reqlog.RequestLog) error { - buf := bytes.Buffer{} - - err := gob.NewEncoder(&buf).Encode(reqLog) +func (db *Database) StoreRequestLog(ctx context.Context, reqLog *reqlog.HttpRequestLog) error { + encReqLog, err := proto.Marshal(reqLog) if err != nil { - return fmt.Errorf("bolt: failed to encode request log: %w", err) + return fmt.Errorf("bolt: failed to marshal request log: %w", err) } err = db.bolt.Update(func(txn *bolt.Tx) error { - b, err := requestLogsBucket(txn, reqLog.ProjectID) + b, err := requestLogsBucket(txn, reqLog.ProjectId) if err != nil { return fmt.Errorf("failed to get request logs bucket: %w", err) } - err = b.Put(reqLog.ID[:], buf.Bytes()) + err = b.Put([]byte(reqLog.Id), encReqLog) if err != nil { return fmt.Errorf("failed to put request log: %w", err) } @@ -140,40 +126,32 @@ func (db *Database) StoreRequestLog(ctx context.Context, reqLog reqlog.RequestLo return nil } -func (db *Database) StoreResponseLog(ctx context.Context, projectID, reqLogID ulid.ULID, resLog reqlog.ResponseLog) error { - buf := bytes.Buffer{} - - err := gob.NewEncoder(&buf).Encode(resLog) - if err != nil { - return fmt.Errorf("bolt: failed to encode response log: %w", err) - } - - err = db.bolt.Update(func(txn *bolt.Tx) error { +func (db *Database) StoreResponseLog(ctx context.Context, projectID, reqLogID string, resLog *http.Response) error { + err := db.bolt.Update(func(txn *bolt.Tx) error { b, err := requestLogsBucket(txn, projectID) if err != nil { return fmt.Errorf("failed to get request logs bucket: %w", err) } - rawReqLog := b.Get(reqLogID[:]) - if rawReqLog == nil { - return reqlog.ErrRequestNotFound + encReqLog := b.Get([]byte(reqLogID)) + if encReqLog == nil { + return reqlog.ErrRequestLogNotFound } - var reqLog reqlog.RequestLog - err = gob.NewDecoder(bytes.NewReader(rawReqLog)).Decode(&reqLog) + var reqLog reqlog.HttpRequestLog + err = proto.Unmarshal(encReqLog, &reqLog) if err != nil { return fmt.Errorf("failed to decode request log: %w", err) } - reqLog.Response = &resLog + reqLog.Response = resLog - buf := bytes.Buffer{} - err = gob.NewEncoder(&buf).Encode(reqLog) + encReqLog, err = proto.Marshal(&reqLog) if err != nil { return fmt.Errorf("failed to encode request log: %w", err) } - err = b.Put(reqLog.ID[:], buf.Bytes()) + err = b.Put([]byte(reqLogID), encReqLog) if err != nil { return fmt.Errorf("failed to put request log: %w", err) } @@ -187,9 +165,9 @@ func (db *Database) StoreResponseLog(ctx context.Context, projectID, reqLogID ul return nil } -func (db *Database) ClearRequestLogs(ctx context.Context, projectID ulid.ULID) error { +func (db *Database) ClearRequestLogs(ctx context.Context, projectID string) error { err := db.bolt.Update(func(txn *bolt.Tx) error { - pb, err := projectBucket(txn, projectID[:]) + pb, err := projectBucket(txn, projectID) if err != nil { return fmt.Errorf("failed to get project bucket: %w", err) } diff --git a/pkg/db/bolt/reqlog_test.go b/pkg/db/bolt/reqlog_test.go index 16df508..7f22575 100644 --- a/pkg/db/bolt/reqlog_test.go +++ b/pkg/db/bolt/reqlog_test.go @@ -2,47 +2,21 @@ package bolt_test import ( "context" - "errors" - "net/http" - "net/url" "testing" - "time" - "github.com/google/go-cmp/cmp" - "github.com/oklog/ulid" + "github.com/oklog/ulid/v2" "go.etcd.io/bbolt" "github.com/dstotijn/hetty/pkg/db/bolt" + "github.com/dstotijn/hetty/pkg/http" "github.com/dstotijn/hetty/pkg/proj" "github.com/dstotijn/hetty/pkg/reqlog" + "github.com/dstotijn/hetty/pkg/testutil" ) func TestFindRequestLogs(t *testing.T) { t.Parallel() - t.Run("without project ID in filter", func(t *testing.T) { - t.Parallel() - - path := t.TempDir() + "bolt.db" - boltDB, err := bbolt.Open(path, 0o600, nil) - if err != nil { - t.Fatalf("failed to open bolt database: %v", err) - } - - db, err := bolt.DatabaseFromBoltDB(boltDB) - if err != nil { - t.Fatalf("failed to create database: %v", err) - } - defer db.Close() - - filter := reqlog.FindRequestsFilter{} - - _, err = db.FindRequestLogs(context.Background(), filter, nil) - if !errors.Is(err, reqlog.ErrProjectIDMustBeSet) { - t.Fatalf("expected `reqlog.ErrProjectIDMustBeSet`, got: %v", err) - } - }) - t.Run("returns request logs and related response logs", func(t *testing.T) { t.Parallel() @@ -58,44 +32,56 @@ func TestFindRequestLogs(t *testing.T) { } defer db.Close() - projectID := ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) + projectID := ulid.Make().String() - err = db.UpsertProject(context.Background(), proj.Project{ - ID: projectID, + err = db.UpsertProject(context.Background(), &proj.Project{ + Id: projectID, }) if err != nil { t.Fatalf("unexpected error upserting project: %v", err) } - fixtures := []reqlog.RequestLog{ + fixtures := []*reqlog.HttpRequestLog{ { - ID: ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy), - ProjectID: projectID, - URL: mustParseURL(t, "https://example.com/foobar"), - Method: http.MethodPost, - Proto: "HTTP/1.1", - Header: http.Header{ - "X-Foo": []string{"baz"}, + Id: ulid.Make().String(), + ProjectId: projectID, + Request: &http.Request{ + Url: "https://example.com/foobar", + Method: http.Method_METHOD_POST, + Protocol: http.Protocol_PROTOCOL_HTTP11, + Headers: []*http.Header{ + {Key: "X-Foo", Value: "baz"}, + }, + Body: []byte("foo"), }, - Body: []byte("foo"), - Response: &reqlog.ResponseLog{ - Proto: "HTTP/1.1", + Response: &http.Response{ Status: "200 OK", StatusCode: 200, - Header: http.Header{ - "X-Yolo": []string{"swag"}, + Headers: []*http.Header{ + {Key: "X-Yolo", Value: "swag"}, }, Body: []byte("bar"), }, }, { - ID: ulid.MustNew(ulid.Timestamp(time.Now())+100, ulidEntropy), - ProjectID: projectID, - URL: mustParseURL(t, "https://example.com/foo?bar=baz"), - Method: http.MethodGet, - Proto: "HTTP/1.1", - Header: http.Header{ - "X-Foo": []string{"baz"}, + Id: ulid.Make().String(), + ProjectId: projectID, + Request: &http.Request{ + Url: "https://example.com/foo?bar=baz", + Method: http.Method_METHOD_GET, + Protocol: http.Protocol_PROTOCOL_HTTP11, + Headers: []*http.Header{ + {Key: "X-Foo", Value: "baz"}, + }, + Body: []byte("foo"), + }, + Response: &http.Response{ + Status: "200 OK", + StatusCode: 200, + Headers: []*http.Header{ + {Key: "X-Yolo", Value: "swag"}, + }, + Body: []byte("bar"), }, }, } @@ -108,34 +94,17 @@ func TestFindRequestLogs(t *testing.T) { } } - filter := reqlog.FindRequestsFilter{ - ProjectID: projectID, - } - - got, err := db.FindRequestLogs(context.Background(), filter, nil) + got, err := db.FindRequestLogs(context.Background(), projectID, nil) if err != nil { t.Fatalf("unexpected error finding request logs: %v", err) } // We expect the found request logs are *reversed*, e.g. newest first. - exp := make([]reqlog.RequestLog, len(fixtures)) + exp := make([]*reqlog.HttpRequestLog, len(fixtures)) for i, j := 0, len(fixtures)-1; i < j; i, j = i+1, j-1 { exp[i], exp[j] = fixtures[j], fixtures[i] } - if diff := cmp.Diff(exp, got); diff != "" { - t.Fatalf("request logs not equal (-exp, +got):\n%v", diff) - } + testutil.ProtoSlicesDiff(t, "request logs not equal", exp, got) }) } - -func mustParseURL(t *testing.T, s string) *url.URL { - t.Helper() - - u, err := url.Parse(s) - if err != nil { - panic(err) - } - - return u -} diff --git a/pkg/db/bolt/sender.go b/pkg/db/bolt/sender.go index a777801..972485c 100644 --- a/pkg/db/bolt/sender.go +++ b/pkg/db/bolt/sender.go @@ -1,16 +1,13 @@ package bolt import ( - "bytes" "context" - "encoding/gob" "errors" "fmt" - "github.com/oklog/ulid" bolt "go.etcd.io/bbolt" + "google.golang.org/protobuf/proto" - "github.com/dstotijn/hetty/pkg/scope" "github.com/dstotijn/hetty/pkg/sender" ) @@ -18,8 +15,8 @@ var ErrSenderRequestsBucketNotFound = errors.New("bolt: sender requests bucket n var senderReqsBucketName = []byte("sender_requests") -func senderReqsBucket(tx *bolt.Tx, projectID ulid.ULID) (*bolt.Bucket, error) { - pb, err := projectBucket(tx, projectID[:]) +func senderReqsBucket(tx *bolt.Tx, projectID string) (*bolt.Bucket, error) { + pb, err := projectBucket(tx, projectID) if err != nil { return nil, err } @@ -32,21 +29,19 @@ func senderReqsBucket(tx *bolt.Tx, projectID ulid.ULID) (*bolt.Bucket, error) { return b, nil } -func (db *Database) StoreSenderRequest(ctx context.Context, req sender.Request) error { - buf := bytes.Buffer{} - - err := gob.NewEncoder(&buf).Encode(req) +func (db *Database) StoreSenderRequest(ctx context.Context, req *sender.Request) error { + rawReq, err := proto.Marshal(req) if err != nil { - return fmt.Errorf("bolt: failed to encode sender request: %w", err) + return fmt.Errorf("bolt: failed to marshal sender request: %w", err) } err = db.bolt.Update(func(tx *bolt.Tx) error { - senderReqsBucket, err := senderReqsBucket(tx, req.ProjectID) + senderReqsBucket, err := senderReqsBucket(tx, req.ProjectId) if err != nil { return fmt.Errorf("failed to get sender requests bucket: %w", err) } - err = senderReqsBucket.Put(req.ID[:], buf.Bytes()) + err = senderReqsBucket.Put([]byte(req.Id), rawReq) if err != nil { return fmt.Errorf("failed to put sender request: %w", err) } @@ -60,9 +55,9 @@ func (db *Database) StoreSenderRequest(ctx context.Context, req sender.Request) return nil } -func (db *Database) FindSenderRequestByID(ctx context.Context, projectID, senderReqID ulid.ULID) (req sender.Request, err error) { - if projectID.Compare(ulid.ULID{}) == 0 { - return sender.Request{}, sender.ErrProjectIDMustBeSet +func (db *Database) FindSenderRequestByID(ctx context.Context, projectID, senderReqID string) (req *sender.Request, err error) { + if projectID == "" { + return nil, sender.ErrProjectIDMustBeSet } err = db.bolt.View(func(tx *bolt.Tx) error { @@ -71,63 +66,49 @@ func (db *Database) FindSenderRequestByID(ctx context.Context, projectID, sender return fmt.Errorf("failed to get sender requests bucket: %w", err) } - rawSenderReq := senderReqsBucket.Get(senderReqID[:]) + rawSenderReq := senderReqsBucket.Get([]byte(senderReqID)) if rawSenderReq == nil { return sender.ErrRequestNotFound } - err = gob.NewDecoder(bytes.NewReader(rawSenderReq)).Decode(&req) + req = &sender.Request{} + err = proto.Unmarshal(rawSenderReq, req) if err != nil { - return fmt.Errorf("failed to decode sender request: %w", err) + return fmt.Errorf("failed to unmarshal sender request: %w", err) } return nil }) if err != nil { - return sender.Request{}, fmt.Errorf("bolt: failed to commit transaction: %w", err) + return nil, fmt.Errorf("bolt: failed to commit transaction: %w", err) } return req, nil } -func (db *Database) FindSenderRequests(ctx context.Context, filter sender.FindRequestsFilter, scope *scope.Scope) (reqs []sender.Request, err error) { - if filter.ProjectID.Compare(ulid.ULID{}) == 0 { - return nil, sender.ErrProjectIDMustBeSet - } - +func (db *Database) FindSenderRequests(ctx context.Context, projectID string, filterFn func(req *sender.Request) (bool, error)) (reqs []*sender.Request, err error) { tx, err := db.bolt.Begin(false) if err != nil { return nil, fmt.Errorf("bolt: failed to begin transaction: %w", err) } defer tx.Rollback() - b, err := senderReqsBucket(tx, filter.ProjectID) + b, err := senderReqsBucket(tx, projectID) if err != nil { return nil, fmt.Errorf("failed to get sender requests bucket: %w", err) } err = b.ForEach(func(senderReqID, rawSenderReq []byte) error { - var req sender.Request - err = gob.NewDecoder(bytes.NewReader(rawSenderReq)).Decode(&req) + req := &sender.Request{} + err = proto.Unmarshal(rawSenderReq, req) if err != nil { - return fmt.Errorf("failed to decode sender request: %w", err) + return fmt.Errorf("failed to unmarshal sender request: %w", err) } - if filter.OnlyInScope { - if !req.MatchScope(scope) { - return nil - } - } - - // Filter by search expression. TODO: Once pagination is introduced, - // this filter logic should be done as items are retrieved. - if filter.SearchExpr != nil { - match, err := req.Matches(filter.SearchExpr) + if filterFn != nil { + match, err := filterFn(req) if err != nil { - return fmt.Errorf( - "bolt: failed to match search expression for sender request (id: %v): %w", - senderReqID, err, - ) + return fmt.Errorf("failed to filter sender request: %w", err) } if !match { @@ -150,7 +131,7 @@ func (db *Database) FindSenderRequests(ctx context.Context, filter sender.FindRe return reqs, nil } -func (db *Database) DeleteSenderRequests(ctx context.Context, projectID ulid.ULID) error { +func (db *Database) DeleteSenderRequests(ctx context.Context, projectID string) error { err := db.bolt.Update(func(tx *bolt.Tx) error { senderReqsBucket, err := senderReqsBucket(tx, projectID) if err != nil { diff --git a/pkg/db/bolt/sender_test.go b/pkg/db/bolt/sender_test.go index 68af0ee..570bdb7 100644 --- a/pkg/db/bolt/sender_test.go +++ b/pkg/db/bolt/sender_test.go @@ -3,19 +3,17 @@ package bolt_test import ( "context" "errors" - "net/http" "net/url" "testing" - "time" - "github.com/google/go-cmp/cmp" - "github.com/oklog/ulid" + "github.com/oklog/ulid/v2" "go.etcd.io/bbolt" "github.com/dstotijn/hetty/pkg/db/bolt" + "github.com/dstotijn/hetty/pkg/http" "github.com/dstotijn/hetty/pkg/proj" - "github.com/dstotijn/hetty/pkg/reqlog" "github.com/dstotijn/hetty/pkg/sender" + "github.com/dstotijn/hetty/pkg/testutil" ) var exampleURL = func() *url.URL { @@ -43,11 +41,11 @@ func TestFindRequestByID(t *testing.T) { } defer db.Close() - projectID := ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) - reqID := ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) + projectID := "foobar-project-id" + reqID := "foobar-req-id" - err = db.UpsertProject(context.Background(), proj.Project{ - ID: projectID, + err = db.UpsertProject(context.Background(), &proj.Project{ + Id: projectID, }) if err != nil { t.Fatalf("unexpected error upserting project: %v", err) @@ -67,24 +65,31 @@ func TestFindRequestByID(t *testing.T) { t.Run("sender request found", func(t *testing.T) { t.Parallel() - exp := sender.Request{ - ID: ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy), - ProjectID: projectID, - SourceRequestLogID: ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy), - - URL: exampleURL, - Method: http.MethodGet, - Proto: sender.HTTPProto20, - Header: http.Header{ - "X-Foo": []string{"bar"}, + exp := &sender.Request{ + Id: "foobar-sender-req-id", + ProjectId: projectID, + SourceRequestLogId: "foobar-req-log-id", + HttpRequest: &http.Request{ + Url: exampleURL.String(), + Method: http.Method_METHOD_GET, + Protocol: http.Protocol_PROTOCOL_HTTP20, + Headers: []*http.Header{ + { + Key: "X-Foo", + Value: "bar", + }, + }, + Body: []byte("foo"), }, - Body: []byte("foo"), - Response: &reqlog.ResponseLog{ - Proto: "HTTP/2.0", + HttpResponse: &http.Response{ + Protocol: http.Protocol_PROTOCOL_HTTP20, Status: "200 OK", StatusCode: 200, - Header: http.Header{ - "X-Yolo": []string{"swag"}, + Headers: []*http.Header{ + { + Key: "X-Yolo", + Value: "swag", + }, }, Body: []byte("bar"), }, @@ -95,14 +100,12 @@ func TestFindRequestByID(t *testing.T) { t.Fatalf("unexpected error (expected: nil, got: %v)", err) } - got, err := db.FindSenderRequestByID(context.Background(), exp.ProjectID, exp.ID) + got, err := db.FindSenderRequestByID(context.Background(), projectID, exp.Id) if err != nil { t.Fatalf("unexpected error (expected: nil, got: %v)", err) } - if diff := cmp.Diff(exp, got); diff != "" { - t.Fatalf("sender request not equal (-exp, +got):\n%v", diff) - } + testutil.ProtoDiff(t, "sender request not equal", exp, got, "id") }) }) } @@ -110,30 +113,6 @@ func TestFindRequestByID(t *testing.T) { func TestFindSenderRequests(t *testing.T) { t.Parallel() - t.Run("without project ID in filter", func(t *testing.T) { - t.Parallel() - - path := t.TempDir() + "bolt.db" - boltDB, err := bbolt.Open(path, 0o600, nil) - if err != nil { - t.Fatalf("failed to open bolt database: %v", err) - } - defer boltDB.Close() - - db, err := bolt.DatabaseFromBoltDB(boltDB) - if err != nil { - t.Fatalf("failed to create database: %v", err) - } - defer db.Close() - - filter := sender.FindRequestsFilter{} - - _, err = db.FindSenderRequests(context.Background(), filter, nil) - if !errors.Is(err, sender.ErrProjectIDMustBeSet) { - t.Fatalf("expected `sender.ErrProjectIDMustBeSet`, got: %v", err) - } - }) - t.Run("returns sender requests and related response logs", func(t *testing.T) { t.Parallel() @@ -150,48 +129,61 @@ func TestFindSenderRequests(t *testing.T) { } defer db.Close() - projectID := ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) + projectID := "foobar-project-id" - err = db.UpsertProject(context.Background(), proj.Project{ - ID: projectID, - Name: "foobar", - Settings: proj.Settings{}, + err = db.UpsertProject(context.Background(), &proj.Project{ + Id: projectID, + Name: "foobar", }) if err != nil { t.Fatalf("unexpected error creating project (expected: nil, got: %v)", err) } - fixtures := []sender.Request{ + fixtures := []*sender.Request{ { - ID: ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy), - ProjectID: projectID, - SourceRequestLogID: ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy), - URL: exampleURL, - Method: http.MethodPost, - Proto: "HTTP/1.1", - Header: http.Header{ - "X-Foo": []string{"baz"}, + Id: ulid.Make().String(), + ProjectId: projectID, + SourceRequestLogId: "foobar-req-log-id-1", + HttpRequest: &http.Request{ + Url: exampleURL.String(), + Method: http.Method_METHOD_POST, + Protocol: http.Protocol_PROTOCOL_HTTP11, + Headers: []*http.Header{ + { + Key: "X-Foo", + Value: "baz", + }, + }, + Body: []byte("foo"), }, - Body: []byte("foo"), - Response: &reqlog.ResponseLog{ - Proto: "HTTP/1.1", + HttpResponse: &http.Response{ + Protocol: http.Protocol_PROTOCOL_HTTP11, Status: "200 OK", StatusCode: 200, - Header: http.Header{ - "X-Yolo": []string{"swag"}, + Headers: []*http.Header{ + { + Key: "X-Yolo", + Value: "swag", + }, }, Body: []byte("bar"), }, }, { - ID: ulid.MustNew(ulid.Timestamp(time.Now())+100, ulidEntropy), - ProjectID: projectID, - SourceRequestLogID: ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy), - URL: exampleURL, - Method: http.MethodGet, - Proto: "HTTP/1.1", - Header: http.Header{ - "X-Foo": []string{"baz"}, + Id: ulid.Make().String(), + ProjectId: projectID, + SourceRequestLogId: "foobar-req-log-id-2", + HttpRequest: &http.Request{ + Url: exampleURL.String(), + Method: http.Method_METHOD_GET, + Protocol: http.Protocol_PROTOCOL_HTTP11, + Headers: []*http.Header{ + { + Key: "X-Foo", + Value: "baz", + }, + }, + Body: []byte("foo"), }, }, } @@ -204,23 +196,17 @@ func TestFindSenderRequests(t *testing.T) { } } - filter := sender.FindRequestsFilter{ - ProjectID: projectID, - } - - got, err := db.FindSenderRequests(context.Background(), filter, nil) + got, err := db.FindSenderRequests(context.Background(), projectID, nil) if err != nil { t.Fatalf("unexpected error finding sender requests: %v", err) } // We expect the found sender requests are *reversed*, e.g. newest first. - exp := make([]sender.Request, len(fixtures)) + exp := make([]*sender.Request, len(fixtures)) for i, j := 0, len(fixtures)-1; i < j; i, j = i+1, j-1 { exp[i], exp[j] = fixtures[j], fixtures[i] } - if diff := cmp.Diff(exp, got); diff != "" { - t.Fatalf("sender requests not equal (-exp, +got):\n%v", diff) - } + testutil.ProtoSlicesDiff(t, "sender requests not equal", exp, got) }) } diff --git a/pkg/filter/http.go b/pkg/filter/http.go index 4a88012..0b1035a 100644 --- a/pkg/filter/http.go +++ b/pkg/filter/http.go @@ -3,10 +3,11 @@ package filter import ( "errors" "fmt" - "net/http" + + "github.com/dstotijn/hetty/pkg/http" ) -func MatchHTTPHeaders(op TokenType, expr Expression, headers http.Header) (bool, error) { +func MatchHTTPHeaders(op TokenType, expr Expression, headers []*http.Header) (bool, error) { if headers == nil { return false, nil } @@ -19,11 +20,9 @@ func MatchHTTPHeaders(op TokenType, expr Expression, headers http.Header) (bool, } // Return `true` if at least one header (: ) is equal to the string literal. - for key, values := range headers { - for _, value := range values { - if strLiteral.Value == fmt.Sprintf("%v: %v", key, value) { - return true, nil - } + for _, header := range headers { + if strLiteral.Value == fmt.Sprintf("%v: %v", header.Key, header.Value) { + return true, nil } } @@ -35,11 +34,9 @@ func MatchHTTPHeaders(op TokenType, expr Expression, headers http.Header) (bool, } // Return `true` if none of the headers (: ) are equal to the string literal. - for key, values := range headers { - for _, value := range values { - if strLiteral.Value == fmt.Sprintf("%v: %v", key, value) { - return false, nil - } + for _, header := range headers { + if strLiteral.Value == fmt.Sprintf("%v: %v", header.Key, header.Value) { + return false, nil } } @@ -51,11 +48,9 @@ func MatchHTTPHeaders(op TokenType, expr Expression, headers http.Header) (bool, } // Return `true` if at least one header (: ) matches the regular expression. - for key, values := range headers { - for _, value := range values { - if re.MatchString(fmt.Sprintf("%v: %v", key, value)) { - return true, nil - } + for _, header := range headers { + if re.Regexp.MatchString(fmt.Sprintf("%v: %v", header.Key, header.Value)) { + return true, nil } } @@ -67,11 +62,9 @@ func MatchHTTPHeaders(op TokenType, expr Expression, headers http.Header) (bool, } // Return `true` if none of the headers (: ) match the regular expression. - for key, values := range headers { - for _, value := range values { - if re.MatchString(fmt.Sprintf("%v: %v", key, value)) { - return false, nil - } + for _, header := range headers { + if re.Regexp.MatchString(fmt.Sprintf("%v: %v", header.Key, header.Value)) { + return false, nil } } diff --git a/pkg/http/http.go b/pkg/http/http.go new file mode 100644 index 0000000..5c26ee9 --- /dev/null +++ b/pkg/http/http.go @@ -0,0 +1,79 @@ +package http + +import ( + "fmt" + "io" + nethttp "net/http" + "strconv" + "strings" +) + +var ProtoMap = map[string]Protocol{ + "HTTP/1.0": Protocol_PROTOCOL_HTTP10, + "HTTP/1.1": Protocol_PROTOCOL_HTTP11, + "HTTP/2.0": Protocol_PROTOCOL_HTTP20, +} + +var MethodMap = map[string]Method{ + "GET": Method_METHOD_GET, + "POST": Method_METHOD_POST, + "PUT": Method_METHOD_PUT, + "DELETE": Method_METHOD_DELETE, + "CONNECT": Method_METHOD_CONNECT, + "OPTIONS": Method_METHOD_OPTIONS, + "TRACE": Method_METHOD_TRACE, + "PATCH": Method_METHOD_PATCH, +} + +func ParseHeader(header nethttp.Header) []*Header { + headers := []*Header{} + + for key, values := range header { + for _, value := range values { + headers = append(headers, &Header{Key: key, Value: value}) + } + } + + return headers +} + +var ResponseSearchKeyFns = map[string]func(rl *Response) string{ + "res.proto": func(rl *Response) string { return rl.GetProtocol().String() }, + "res.status": func(rl *Response) string { return rl.GetStatus() }, + "res.statusCode": func(rl *Response) string { return strconv.Itoa(int(rl.GetStatusCode())) }, + "res.statusReason": func(rl *Response) string { + statusReasonSubs := strings.SplitN(rl.GetStatus(), " ", 2) + if len(statusReasonSubs) != 2 { + return "" + } + return statusReasonSubs[1] + }, + "res.body": func(rl *Response) string { return string(rl.GetBody()) }, +} + +func ParseHTTPResponse(res *nethttp.Response) (*Response, error) { + body, err := io.ReadAll(res.Body) + if err != nil { + return nil, fmt.Errorf("reqlog: could not read body: %w", err) + } + + headers := []*Header{} + for k, v := range res.Header { + for _, vv := range v { + headers = append(headers, &Header{Key: k, Value: vv}) + } + } + + protocol, ok := ProtoMap[res.Proto] + if !ok { + return nil, fmt.Errorf("reqlog: invalid protocol %q", res.Proto) + } + + return &Response{ + Protocol: protocol, + Status: res.Status, + StatusCode: int32(res.StatusCode), + Headers: headers, + Body: body, + }, nil +} diff --git a/pkg/http/http.pb.go b/pkg/http/http.pb.go new file mode 100644 index 0000000..12f350a --- /dev/null +++ b/pkg/http/http.pb.go @@ -0,0 +1,476 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.3 +// protoc (unknown) +// source: http/http.proto + +package http + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Method int32 + +const ( + Method_METHOD_UNSPECIFIED Method = 0 + Method_METHOD_GET Method = 1 + Method_METHOD_HEAD Method = 2 + Method_METHOD_POST Method = 3 + Method_METHOD_PUT Method = 4 + Method_METHOD_DELETE Method = 5 + Method_METHOD_CONNECT Method = 6 + Method_METHOD_OPTIONS Method = 7 + Method_METHOD_TRACE Method = 8 + Method_METHOD_PATCH Method = 9 +) + +// Enum value maps for Method. +var ( + Method_name = map[int32]string{ + 0: "METHOD_UNSPECIFIED", + 1: "METHOD_GET", + 2: "METHOD_HEAD", + 3: "METHOD_POST", + 4: "METHOD_PUT", + 5: "METHOD_DELETE", + 6: "METHOD_CONNECT", + 7: "METHOD_OPTIONS", + 8: "METHOD_TRACE", + 9: "METHOD_PATCH", + } + Method_value = map[string]int32{ + "METHOD_UNSPECIFIED": 0, + "METHOD_GET": 1, + "METHOD_HEAD": 2, + "METHOD_POST": 3, + "METHOD_PUT": 4, + "METHOD_DELETE": 5, + "METHOD_CONNECT": 6, + "METHOD_OPTIONS": 7, + "METHOD_TRACE": 8, + "METHOD_PATCH": 9, + } +) + +func (x Method) Enum() *Method { + p := new(Method) + *p = x + return p +} + +func (x Method) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Method) Descriptor() protoreflect.EnumDescriptor { + return file_http_http_proto_enumTypes[0].Descriptor() +} + +func (Method) Type() protoreflect.EnumType { + return &file_http_http_proto_enumTypes[0] +} + +func (x Method) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Method.Descriptor instead. +func (Method) EnumDescriptor() ([]byte, []int) { + return file_http_http_proto_rawDescGZIP(), []int{0} +} + +type Protocol int32 + +const ( + Protocol_PROTOCOL_UNSPECIFIED Protocol = 0 + Protocol_PROTOCOL_HTTP10 Protocol = 1 + Protocol_PROTOCOL_HTTP11 Protocol = 2 + Protocol_PROTOCOL_HTTP20 Protocol = 3 +) + +// Enum value maps for Protocol. +var ( + Protocol_name = map[int32]string{ + 0: "PROTOCOL_UNSPECIFIED", + 1: "PROTOCOL_HTTP10", + 2: "PROTOCOL_HTTP11", + 3: "PROTOCOL_HTTP20", + } + Protocol_value = map[string]int32{ + "PROTOCOL_UNSPECIFIED": 0, + "PROTOCOL_HTTP10": 1, + "PROTOCOL_HTTP11": 2, + "PROTOCOL_HTTP20": 3, + } +) + +func (x Protocol) Enum() *Protocol { + p := new(Protocol) + *p = x + return p +} + +func (x Protocol) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Protocol) Descriptor() protoreflect.EnumDescriptor { + return file_http_http_proto_enumTypes[1].Descriptor() +} + +func (Protocol) Type() protoreflect.EnumType { + return &file_http_http_proto_enumTypes[1] +} + +func (x Protocol) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Protocol.Descriptor instead. +func (Protocol) EnumDescriptor() ([]byte, []int) { + return file_http_http_proto_rawDescGZIP(), []int{1} +} + +type Request struct { + state protoimpl.MessageState `protogen:"open.v1"` + Method Method `protobuf:"varint,1,opt,name=method,proto3,enum=hetty.http.v1.Method" json:"method,omitempty"` + Protocol Protocol `protobuf:"varint,2,opt,name=protocol,proto3,enum=hetty.http.v1.Protocol" json:"protocol,omitempty"` + Url string `protobuf:"bytes,3,opt,name=url,proto3" json:"url,omitempty"` + Headers []*Header `protobuf:"bytes,4,rep,name=headers,proto3" json:"headers,omitempty"` + Body []byte `protobuf:"bytes,5,opt,name=body,proto3" json:"body,omitempty"` + Response *Response `protobuf:"bytes,6,opt,name=response,proto3" json:"response,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Request) Reset() { + *x = Request{} + mi := &file_http_http_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Request) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Request) ProtoMessage() {} + +func (x *Request) ProtoReflect() protoreflect.Message { + mi := &file_http_http_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Request.ProtoReflect.Descriptor instead. +func (*Request) Descriptor() ([]byte, []int) { + return file_http_http_proto_rawDescGZIP(), []int{0} +} + +func (x *Request) GetMethod() Method { + if x != nil { + return x.Method + } + return Method_METHOD_UNSPECIFIED +} + +func (x *Request) GetProtocol() Protocol { + if x != nil { + return x.Protocol + } + return Protocol_PROTOCOL_UNSPECIFIED +} + +func (x *Request) GetUrl() string { + if x != nil { + return x.Url + } + return "" +} + +func (x *Request) GetHeaders() []*Header { + if x != nil { + return x.Headers + } + return nil +} + +func (x *Request) GetBody() []byte { + if x != nil { + return x.Body + } + return nil +} + +func (x *Request) GetResponse() *Response { + if x != nil { + return x.Response + } + return nil +} + +type Response struct { + state protoimpl.MessageState `protogen:"open.v1"` + Protocol Protocol `protobuf:"varint,1,opt,name=protocol,proto3,enum=hetty.http.v1.Protocol" json:"protocol,omitempty"` + Status string `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"` + StatusCode int32 `protobuf:"varint,3,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` + Headers []*Header `protobuf:"bytes,5,rep,name=headers,proto3" json:"headers,omitempty"` + Body []byte `protobuf:"bytes,6,opt,name=body,proto3" json:"body,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Response) Reset() { + *x = Response{} + mi := &file_http_http_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Response) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Response) ProtoMessage() {} + +func (x *Response) ProtoReflect() protoreflect.Message { + mi := &file_http_http_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Response.ProtoReflect.Descriptor instead. +func (*Response) Descriptor() ([]byte, []int) { + return file_http_http_proto_rawDescGZIP(), []int{1} +} + +func (x *Response) GetProtocol() Protocol { + if x != nil { + return x.Protocol + } + return Protocol_PROTOCOL_UNSPECIFIED +} + +func (x *Response) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + +func (x *Response) GetStatusCode() int32 { + if x != nil { + return x.StatusCode + } + return 0 +} + +func (x *Response) GetHeaders() []*Header { + if x != nil { + return x.Headers + } + return nil +} + +func (x *Response) GetBody() []byte { + if x != nil { + return x.Body + } + return nil +} + +type Header struct { + state protoimpl.MessageState `protogen:"open.v1"` + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Header) Reset() { + *x = Header{} + mi := &file_http_http_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Header) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Header) ProtoMessage() {} + +func (x *Header) ProtoReflect() protoreflect.Message { + mi := &file_http_http_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Header.ProtoReflect.Descriptor instead. +func (*Header) Descriptor() ([]byte, []int) { + return file_http_http_proto_rawDescGZIP(), []int{2} +} + +func (x *Header) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +func (x *Header) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +var File_http_http_proto protoreflect.FileDescriptor + +var file_http_http_proto_rawDesc = []byte{ + 0x0a, 0x0f, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x0d, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x76, 0x31, + 0x22, 0xf9, 0x01, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2d, 0x0a, 0x06, + 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x68, + 0x65, 0x74, 0x74, 0x79, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x74, + 0x68, 0x6f, 0x64, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x33, 0x0a, 0x08, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, + 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, + 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, + 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, + 0x72, 0x6c, 0x12, 0x2f, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x68, 0x74, 0x74, 0x70, + 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x33, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x68, 0x65, 0x74, 0x74, + 0x79, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xbd, 0x01, 0x0a, + 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x33, 0x0a, 0x08, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x68, 0x65, + 0x74, 0x74, 0x79, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x74, + 0x6f, 0x63, 0x6f, 0x6c, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x16, + 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x2f, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, + 0x2e, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, + 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x30, 0x0a, 0x06, + 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2a, 0xc1, + 0x01, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x16, 0x0a, 0x12, 0x4d, 0x45, 0x54, + 0x48, 0x4f, 0x44, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, + 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x4d, 0x45, 0x54, 0x48, 0x4f, 0x44, 0x5f, 0x47, 0x45, 0x54, 0x10, + 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x4d, 0x45, 0x54, 0x48, 0x4f, 0x44, 0x5f, 0x48, 0x45, 0x41, 0x44, + 0x10, 0x02, 0x12, 0x0f, 0x0a, 0x0b, 0x4d, 0x45, 0x54, 0x48, 0x4f, 0x44, 0x5f, 0x50, 0x4f, 0x53, + 0x54, 0x10, 0x03, 0x12, 0x0e, 0x0a, 0x0a, 0x4d, 0x45, 0x54, 0x48, 0x4f, 0x44, 0x5f, 0x50, 0x55, + 0x54, 0x10, 0x04, 0x12, 0x11, 0x0a, 0x0d, 0x4d, 0x45, 0x54, 0x48, 0x4f, 0x44, 0x5f, 0x44, 0x45, + 0x4c, 0x45, 0x54, 0x45, 0x10, 0x05, 0x12, 0x12, 0x0a, 0x0e, 0x4d, 0x45, 0x54, 0x48, 0x4f, 0x44, + 0x5f, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x10, 0x06, 0x12, 0x12, 0x0a, 0x0e, 0x4d, 0x45, + 0x54, 0x48, 0x4f, 0x44, 0x5f, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0x10, 0x07, 0x12, 0x10, + 0x0a, 0x0c, 0x4d, 0x45, 0x54, 0x48, 0x4f, 0x44, 0x5f, 0x54, 0x52, 0x41, 0x43, 0x45, 0x10, 0x08, + 0x12, 0x10, 0x0a, 0x0c, 0x4d, 0x45, 0x54, 0x48, 0x4f, 0x44, 0x5f, 0x50, 0x41, 0x54, 0x43, 0x48, + 0x10, 0x09, 0x2a, 0x63, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x18, + 0x0a, 0x14, 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x43, 0x4f, 0x4c, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, + 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0f, 0x50, 0x52, 0x4f, 0x54, + 0x4f, 0x43, 0x4f, 0x4c, 0x5f, 0x48, 0x54, 0x54, 0x50, 0x31, 0x30, 0x10, 0x01, 0x12, 0x13, 0x0a, + 0x0f, 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x43, 0x4f, 0x4c, 0x5f, 0x48, 0x54, 0x54, 0x50, 0x31, 0x31, + 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x43, 0x4f, 0x4c, 0x5f, 0x48, + 0x54, 0x54, 0x50, 0x32, 0x30, 0x10, 0x03, 0x42, 0x24, 0x5a, 0x22, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x73, 0x74, 0x6f, 0x74, 0x69, 0x6a, 0x6e, 0x2f, 0x68, + 0x65, 0x74, 0x74, 0x79, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_http_http_proto_rawDescOnce sync.Once + file_http_http_proto_rawDescData = file_http_http_proto_rawDesc +) + +func file_http_http_proto_rawDescGZIP() []byte { + file_http_http_proto_rawDescOnce.Do(func() { + file_http_http_proto_rawDescData = protoimpl.X.CompressGZIP(file_http_http_proto_rawDescData) + }) + return file_http_http_proto_rawDescData +} + +var file_http_http_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_http_http_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_http_http_proto_goTypes = []any{ + (Method)(0), // 0: hetty.http.v1.Method + (Protocol)(0), // 1: hetty.http.v1.Protocol + (*Request)(nil), // 2: hetty.http.v1.Request + (*Response)(nil), // 3: hetty.http.v1.Response + (*Header)(nil), // 4: hetty.http.v1.Header +} +var file_http_http_proto_depIdxs = []int32{ + 0, // 0: hetty.http.v1.Request.method:type_name -> hetty.http.v1.Method + 1, // 1: hetty.http.v1.Request.protocol:type_name -> hetty.http.v1.Protocol + 4, // 2: hetty.http.v1.Request.headers:type_name -> hetty.http.v1.Header + 3, // 3: hetty.http.v1.Request.response:type_name -> hetty.http.v1.Response + 1, // 4: hetty.http.v1.Response.protocol:type_name -> hetty.http.v1.Protocol + 4, // 5: hetty.http.v1.Response.headers:type_name -> hetty.http.v1.Header + 6, // [6:6] is the sub-list for method output_type + 6, // [6:6] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name +} + +func init() { file_http_http_proto_init() } +func file_http_http_proto_init() { + if File_http_http_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_http_http_proto_rawDesc, + NumEnums: 2, + NumMessages: 3, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_http_http_proto_goTypes, + DependencyIndexes: file_http_http_proto_depIdxs, + EnumInfos: file_http_http_proto_enumTypes, + MessageInfos: file_http_http_proto_msgTypes, + }.Build() + File_http_http_proto = out.File + file_http_http_proto_rawDesc = nil + file_http_http_proto_goTypes = nil + file_http_http_proto_depIdxs = nil +} diff --git a/pkg/proj/proj.connect.go b/pkg/proj/proj.connect.go new file mode 100644 index 0000000..b537b5d --- /dev/null +++ b/pkg/proj/proj.connect.go @@ -0,0 +1,340 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: proj/proj.proto + +package proj + +import ( + connect "connectrpc.com/connect" + context "context" + errors "errors" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion1_13_0 + +const ( + // ProjectServiceName is the fully-qualified name of the ProjectService service. + ProjectServiceName = "hetty.proj.v1.ProjectService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // ProjectServiceCreateProjectProcedure is the fully-qualified name of the ProjectService's + // CreateProject RPC. + ProjectServiceCreateProjectProcedure = "/hetty.proj.v1.ProjectService/CreateProject" + // ProjectServiceOpenProjectProcedure is the fully-qualified name of the ProjectService's + // OpenProject RPC. + ProjectServiceOpenProjectProcedure = "/hetty.proj.v1.ProjectService/OpenProject" + // ProjectServiceCloseProjectProcedure is the fully-qualified name of the ProjectService's + // CloseProject RPC. + ProjectServiceCloseProjectProcedure = "/hetty.proj.v1.ProjectService/CloseProject" + // ProjectServiceDeleteProjectProcedure is the fully-qualified name of the ProjectService's + // DeleteProject RPC. + ProjectServiceDeleteProjectProcedure = "/hetty.proj.v1.ProjectService/DeleteProject" + // ProjectServiceGetActiveProjectProcedure is the fully-qualified name of the ProjectService's + // GetActiveProject RPC. + ProjectServiceGetActiveProjectProcedure = "/hetty.proj.v1.ProjectService/GetActiveProject" + // ProjectServiceListProjectsProcedure is the fully-qualified name of the ProjectService's + // ListProjects RPC. + ProjectServiceListProjectsProcedure = "/hetty.proj.v1.ProjectService/ListProjects" + // ProjectServiceUpdateInterceptSettingsProcedure is the fully-qualified name of the + // ProjectService's UpdateInterceptSettings RPC. + ProjectServiceUpdateInterceptSettingsProcedure = "/hetty.proj.v1.ProjectService/UpdateInterceptSettings" + // ProjectServiceSetScopeRulesProcedure is the fully-qualified name of the ProjectService's + // SetScopeRules RPC. + ProjectServiceSetScopeRulesProcedure = "/hetty.proj.v1.ProjectService/SetScopeRules" + // ProjectServiceSetRequestLogsFilterProcedure is the fully-qualified name of the ProjectService's + // SetRequestLogsFilter RPC. + ProjectServiceSetRequestLogsFilterProcedure = "/hetty.proj.v1.ProjectService/SetRequestLogsFilter" +) + +// ProjectServiceClient is a client for the hetty.proj.v1.ProjectService service. +type ProjectServiceClient interface { + CreateProject(context.Context, *connect.Request[CreateProjectRequest]) (*connect.Response[CreateProjectResponse], error) + OpenProject(context.Context, *connect.Request[OpenProjectRequest]) (*connect.Response[OpenProjectResponse], error) + CloseProject(context.Context, *connect.Request[CloseProjectRequest]) (*connect.Response[CloseProjectResponse], error) + DeleteProject(context.Context, *connect.Request[DeleteProjectRequest]) (*connect.Response[DeleteProjectResponse], error) + GetActiveProject(context.Context, *connect.Request[GetActiveProjectRequest]) (*connect.Response[GetActiveProjectResponse], error) + ListProjects(context.Context, *connect.Request[ListProjectsRequest]) (*connect.Response[ListProjectsResponse], error) + UpdateInterceptSettings(context.Context, *connect.Request[UpdateInterceptSettingsRequest]) (*connect.Response[UpdateInterceptSettingsResponse], error) + SetScopeRules(context.Context, *connect.Request[SetScopeRulesRequest]) (*connect.Response[SetScopeRulesResponse], error) + SetRequestLogsFilter(context.Context, *connect.Request[SetRequestLogsFilterRequest]) (*connect.Response[SetRequestLogsFilterResponse], error) +} + +// NewProjectServiceClient constructs a client for the hetty.proj.v1.ProjectService service. By +// default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, +// and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the +// connect.WithGRPC() or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewProjectServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) ProjectServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + projectServiceMethods := File_proj_proj_proto.Services().ByName("ProjectService").Methods() + return &projectServiceClient{ + createProject: connect.NewClient[CreateProjectRequest, CreateProjectResponse]( + httpClient, + baseURL+ProjectServiceCreateProjectProcedure, + connect.WithSchema(projectServiceMethods.ByName("CreateProject")), + connect.WithClientOptions(opts...), + ), + openProject: connect.NewClient[OpenProjectRequest, OpenProjectResponse]( + httpClient, + baseURL+ProjectServiceOpenProjectProcedure, + connect.WithSchema(projectServiceMethods.ByName("OpenProject")), + connect.WithClientOptions(opts...), + ), + closeProject: connect.NewClient[CloseProjectRequest, CloseProjectResponse]( + httpClient, + baseURL+ProjectServiceCloseProjectProcedure, + connect.WithSchema(projectServiceMethods.ByName("CloseProject")), + connect.WithClientOptions(opts...), + ), + deleteProject: connect.NewClient[DeleteProjectRequest, DeleteProjectResponse]( + httpClient, + baseURL+ProjectServiceDeleteProjectProcedure, + connect.WithSchema(projectServiceMethods.ByName("DeleteProject")), + connect.WithClientOptions(opts...), + ), + getActiveProject: connect.NewClient[GetActiveProjectRequest, GetActiveProjectResponse]( + httpClient, + baseURL+ProjectServiceGetActiveProjectProcedure, + connect.WithSchema(projectServiceMethods.ByName("GetActiveProject")), + connect.WithClientOptions(opts...), + ), + listProjects: connect.NewClient[ListProjectsRequest, ListProjectsResponse]( + httpClient, + baseURL+ProjectServiceListProjectsProcedure, + connect.WithSchema(projectServiceMethods.ByName("ListProjects")), + connect.WithClientOptions(opts...), + ), + updateInterceptSettings: connect.NewClient[UpdateInterceptSettingsRequest, UpdateInterceptSettingsResponse]( + httpClient, + baseURL+ProjectServiceUpdateInterceptSettingsProcedure, + connect.WithSchema(projectServiceMethods.ByName("UpdateInterceptSettings")), + connect.WithClientOptions(opts...), + ), + setScopeRules: connect.NewClient[SetScopeRulesRequest, SetScopeRulesResponse]( + httpClient, + baseURL+ProjectServiceSetScopeRulesProcedure, + connect.WithSchema(projectServiceMethods.ByName("SetScopeRules")), + connect.WithClientOptions(opts...), + ), + setRequestLogsFilter: connect.NewClient[SetRequestLogsFilterRequest, SetRequestLogsFilterResponse]( + httpClient, + baseURL+ProjectServiceSetRequestLogsFilterProcedure, + connect.WithSchema(projectServiceMethods.ByName("SetRequestLogsFilter")), + connect.WithClientOptions(opts...), + ), + } +} + +// projectServiceClient implements ProjectServiceClient. +type projectServiceClient struct { + createProject *connect.Client[CreateProjectRequest, CreateProjectResponse] + openProject *connect.Client[OpenProjectRequest, OpenProjectResponse] + closeProject *connect.Client[CloseProjectRequest, CloseProjectResponse] + deleteProject *connect.Client[DeleteProjectRequest, DeleteProjectResponse] + getActiveProject *connect.Client[GetActiveProjectRequest, GetActiveProjectResponse] + listProjects *connect.Client[ListProjectsRequest, ListProjectsResponse] + updateInterceptSettings *connect.Client[UpdateInterceptSettingsRequest, UpdateInterceptSettingsResponse] + setScopeRules *connect.Client[SetScopeRulesRequest, SetScopeRulesResponse] + setRequestLogsFilter *connect.Client[SetRequestLogsFilterRequest, SetRequestLogsFilterResponse] +} + +// CreateProject calls hetty.proj.v1.ProjectService.CreateProject. +func (c *projectServiceClient) CreateProject(ctx context.Context, req *connect.Request[CreateProjectRequest]) (*connect.Response[CreateProjectResponse], error) { + return c.createProject.CallUnary(ctx, req) +} + +// OpenProject calls hetty.proj.v1.ProjectService.OpenProject. +func (c *projectServiceClient) OpenProject(ctx context.Context, req *connect.Request[OpenProjectRequest]) (*connect.Response[OpenProjectResponse], error) { + return c.openProject.CallUnary(ctx, req) +} + +// CloseProject calls hetty.proj.v1.ProjectService.CloseProject. +func (c *projectServiceClient) CloseProject(ctx context.Context, req *connect.Request[CloseProjectRequest]) (*connect.Response[CloseProjectResponse], error) { + return c.closeProject.CallUnary(ctx, req) +} + +// DeleteProject calls hetty.proj.v1.ProjectService.DeleteProject. +func (c *projectServiceClient) DeleteProject(ctx context.Context, req *connect.Request[DeleteProjectRequest]) (*connect.Response[DeleteProjectResponse], error) { + return c.deleteProject.CallUnary(ctx, req) +} + +// GetActiveProject calls hetty.proj.v1.ProjectService.GetActiveProject. +func (c *projectServiceClient) GetActiveProject(ctx context.Context, req *connect.Request[GetActiveProjectRequest]) (*connect.Response[GetActiveProjectResponse], error) { + return c.getActiveProject.CallUnary(ctx, req) +} + +// ListProjects calls hetty.proj.v1.ProjectService.ListProjects. +func (c *projectServiceClient) ListProjects(ctx context.Context, req *connect.Request[ListProjectsRequest]) (*connect.Response[ListProjectsResponse], error) { + return c.listProjects.CallUnary(ctx, req) +} + +// UpdateInterceptSettings calls hetty.proj.v1.ProjectService.UpdateInterceptSettings. +func (c *projectServiceClient) UpdateInterceptSettings(ctx context.Context, req *connect.Request[UpdateInterceptSettingsRequest]) (*connect.Response[UpdateInterceptSettingsResponse], error) { + return c.updateInterceptSettings.CallUnary(ctx, req) +} + +// SetScopeRules calls hetty.proj.v1.ProjectService.SetScopeRules. +func (c *projectServiceClient) SetScopeRules(ctx context.Context, req *connect.Request[SetScopeRulesRequest]) (*connect.Response[SetScopeRulesResponse], error) { + return c.setScopeRules.CallUnary(ctx, req) +} + +// SetRequestLogsFilter calls hetty.proj.v1.ProjectService.SetRequestLogsFilter. +func (c *projectServiceClient) SetRequestLogsFilter(ctx context.Context, req *connect.Request[SetRequestLogsFilterRequest]) (*connect.Response[SetRequestLogsFilterResponse], error) { + return c.setRequestLogsFilter.CallUnary(ctx, req) +} + +// ProjectServiceHandler is an implementation of the hetty.proj.v1.ProjectService service. +type ProjectServiceHandler interface { + CreateProject(context.Context, *connect.Request[CreateProjectRequest]) (*connect.Response[CreateProjectResponse], error) + OpenProject(context.Context, *connect.Request[OpenProjectRequest]) (*connect.Response[OpenProjectResponse], error) + CloseProject(context.Context, *connect.Request[CloseProjectRequest]) (*connect.Response[CloseProjectResponse], error) + DeleteProject(context.Context, *connect.Request[DeleteProjectRequest]) (*connect.Response[DeleteProjectResponse], error) + GetActiveProject(context.Context, *connect.Request[GetActiveProjectRequest]) (*connect.Response[GetActiveProjectResponse], error) + ListProjects(context.Context, *connect.Request[ListProjectsRequest]) (*connect.Response[ListProjectsResponse], error) + UpdateInterceptSettings(context.Context, *connect.Request[UpdateInterceptSettingsRequest]) (*connect.Response[UpdateInterceptSettingsResponse], error) + SetScopeRules(context.Context, *connect.Request[SetScopeRulesRequest]) (*connect.Response[SetScopeRulesResponse], error) + SetRequestLogsFilter(context.Context, *connect.Request[SetRequestLogsFilterRequest]) (*connect.Response[SetRequestLogsFilterResponse], error) +} + +// NewProjectServiceHandler builds an HTTP handler from the service implementation. It returns the +// path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewProjectServiceHandler(svc ProjectServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + projectServiceMethods := File_proj_proj_proto.Services().ByName("ProjectService").Methods() + projectServiceCreateProjectHandler := connect.NewUnaryHandler( + ProjectServiceCreateProjectProcedure, + svc.CreateProject, + connect.WithSchema(projectServiceMethods.ByName("CreateProject")), + connect.WithHandlerOptions(opts...), + ) + projectServiceOpenProjectHandler := connect.NewUnaryHandler( + ProjectServiceOpenProjectProcedure, + svc.OpenProject, + connect.WithSchema(projectServiceMethods.ByName("OpenProject")), + connect.WithHandlerOptions(opts...), + ) + projectServiceCloseProjectHandler := connect.NewUnaryHandler( + ProjectServiceCloseProjectProcedure, + svc.CloseProject, + connect.WithSchema(projectServiceMethods.ByName("CloseProject")), + connect.WithHandlerOptions(opts...), + ) + projectServiceDeleteProjectHandler := connect.NewUnaryHandler( + ProjectServiceDeleteProjectProcedure, + svc.DeleteProject, + connect.WithSchema(projectServiceMethods.ByName("DeleteProject")), + connect.WithHandlerOptions(opts...), + ) + projectServiceGetActiveProjectHandler := connect.NewUnaryHandler( + ProjectServiceGetActiveProjectProcedure, + svc.GetActiveProject, + connect.WithSchema(projectServiceMethods.ByName("GetActiveProject")), + connect.WithHandlerOptions(opts...), + ) + projectServiceListProjectsHandler := connect.NewUnaryHandler( + ProjectServiceListProjectsProcedure, + svc.ListProjects, + connect.WithSchema(projectServiceMethods.ByName("ListProjects")), + connect.WithHandlerOptions(opts...), + ) + projectServiceUpdateInterceptSettingsHandler := connect.NewUnaryHandler( + ProjectServiceUpdateInterceptSettingsProcedure, + svc.UpdateInterceptSettings, + connect.WithSchema(projectServiceMethods.ByName("UpdateInterceptSettings")), + connect.WithHandlerOptions(opts...), + ) + projectServiceSetScopeRulesHandler := connect.NewUnaryHandler( + ProjectServiceSetScopeRulesProcedure, + svc.SetScopeRules, + connect.WithSchema(projectServiceMethods.ByName("SetScopeRules")), + connect.WithHandlerOptions(opts...), + ) + projectServiceSetRequestLogsFilterHandler := connect.NewUnaryHandler( + ProjectServiceSetRequestLogsFilterProcedure, + svc.SetRequestLogsFilter, + connect.WithSchema(projectServiceMethods.ByName("SetRequestLogsFilter")), + connect.WithHandlerOptions(opts...), + ) + return "/hetty.proj.v1.ProjectService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case ProjectServiceCreateProjectProcedure: + projectServiceCreateProjectHandler.ServeHTTP(w, r) + case ProjectServiceOpenProjectProcedure: + projectServiceOpenProjectHandler.ServeHTTP(w, r) + case ProjectServiceCloseProjectProcedure: + projectServiceCloseProjectHandler.ServeHTTP(w, r) + case ProjectServiceDeleteProjectProcedure: + projectServiceDeleteProjectHandler.ServeHTTP(w, r) + case ProjectServiceGetActiveProjectProcedure: + projectServiceGetActiveProjectHandler.ServeHTTP(w, r) + case ProjectServiceListProjectsProcedure: + projectServiceListProjectsHandler.ServeHTTP(w, r) + case ProjectServiceUpdateInterceptSettingsProcedure: + projectServiceUpdateInterceptSettingsHandler.ServeHTTP(w, r) + case ProjectServiceSetScopeRulesProcedure: + projectServiceSetScopeRulesHandler.ServeHTTP(w, r) + case ProjectServiceSetRequestLogsFilterProcedure: + projectServiceSetRequestLogsFilterHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedProjectServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedProjectServiceHandler struct{} + +func (UnimplementedProjectServiceHandler) CreateProject(context.Context, *connect.Request[CreateProjectRequest]) (*connect.Response[CreateProjectResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hetty.proj.v1.ProjectService.CreateProject is not implemented")) +} + +func (UnimplementedProjectServiceHandler) OpenProject(context.Context, *connect.Request[OpenProjectRequest]) (*connect.Response[OpenProjectResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hetty.proj.v1.ProjectService.OpenProject is not implemented")) +} + +func (UnimplementedProjectServiceHandler) CloseProject(context.Context, *connect.Request[CloseProjectRequest]) (*connect.Response[CloseProjectResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hetty.proj.v1.ProjectService.CloseProject is not implemented")) +} + +func (UnimplementedProjectServiceHandler) DeleteProject(context.Context, *connect.Request[DeleteProjectRequest]) (*connect.Response[DeleteProjectResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hetty.proj.v1.ProjectService.DeleteProject is not implemented")) +} + +func (UnimplementedProjectServiceHandler) GetActiveProject(context.Context, *connect.Request[GetActiveProjectRequest]) (*connect.Response[GetActiveProjectResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hetty.proj.v1.ProjectService.GetActiveProject is not implemented")) +} + +func (UnimplementedProjectServiceHandler) ListProjects(context.Context, *connect.Request[ListProjectsRequest]) (*connect.Response[ListProjectsResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hetty.proj.v1.ProjectService.ListProjects is not implemented")) +} + +func (UnimplementedProjectServiceHandler) UpdateInterceptSettings(context.Context, *connect.Request[UpdateInterceptSettingsRequest]) (*connect.Response[UpdateInterceptSettingsResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hetty.proj.v1.ProjectService.UpdateInterceptSettings is not implemented")) +} + +func (UnimplementedProjectServiceHandler) SetScopeRules(context.Context, *connect.Request[SetScopeRulesRequest]) (*connect.Response[SetScopeRulesResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hetty.proj.v1.ProjectService.SetScopeRules is not implemented")) +} + +func (UnimplementedProjectServiceHandler) SetRequestLogsFilter(context.Context, *connect.Request[SetRequestLogsFilterRequest]) (*connect.Response[SetRequestLogsFilterResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hetty.proj.v1.ProjectService.SetRequestLogsFilter is not implemented")) +} diff --git a/pkg/proj/proj.go b/pkg/proj/proj.go index f3bfde0..9bc91ab 100644 --- a/pkg/proj/proj.go +++ b/pkg/proj/proj.go @@ -4,12 +4,11 @@ import ( "context" "errors" "fmt" - "math/rand" "regexp" "sync" - "time" - "github.com/oklog/ulid" + connect "connectrpc.com/connect" + "github.com/oklog/ulid/v2" "github.com/dstotijn/hetty/pkg/filter" "github.com/dstotijn/hetty/pkg/proxy/intercept" @@ -18,27 +17,16 @@ import ( "github.com/dstotijn/hetty/pkg/sender" ) -//nolint:gosec -var ulidEntropy = rand.New(rand.NewSource(time.Now().UnixNano())) - type Service struct { repo Repository interceptSvc *intercept.Service reqLogSvc *reqlog.Service senderSvc *sender.Service scope *scope.Scope - activeProjectID ulid.ULID + activeProjectID string mu sync.RWMutex } -type Project struct { - ID ulid.ULID - Name string - Settings Settings - - isActive bool -} - type Settings struct { // Request log settings ReqLogBypassOutOfScope bool @@ -87,216 +75,324 @@ func NewService(cfg Config) (*Service, error) { }, nil } -func (svc *Service) CreateProject(ctx context.Context, name string) (Project, error) { - if !nameRegexp.MatchString(name) { - return Project{}, ErrInvalidName +func (svc *Service) CreateProject(ctx context.Context, req *connect.Request[CreateProjectRequest]) (*connect.Response[CreateProjectResponse], error) { + if !nameRegexp.MatchString(req.Msg.Name) { + return nil, ErrInvalidName } - project := Project{ - ID: ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy), - Name: name, + project := &Project{ + Id: ulid.Make().String(), + Name: req.Msg.Name, } err := svc.repo.UpsertProject(ctx, project) if err != nil { - return Project{}, fmt.Errorf("proj: could not create project: %w", err) + return nil, fmt.Errorf("proj: could not create project: %w", err) } - return project, nil + return &connect.Response[CreateProjectResponse]{ + Msg: &CreateProjectResponse{ + Project: project, + }, + }, nil } // CloseProject closes the currently open project (if there is one). -func (svc *Service) CloseProject() error { +func (svc *Service) CloseProject(ctx context.Context, _ *connect.Request[CloseProjectRequest]) (*connect.Response[CloseProjectResponse], error) { svc.mu.Lock() defer svc.mu.Unlock() - if svc.activeProjectID.Compare(ulid.ULID{}) == 0 { - return nil + if svc.activeProjectID == "" { + return nil, connect.NewError(connect.CodeFailedPrecondition, ErrNoProject) } - svc.activeProjectID = ulid.ULID{} - svc.reqLogSvc.SetActiveProjectID(ulid.ULID{}) + svc.activeProjectID = "" + svc.reqLogSvc.SetActiveProjectID("") svc.reqLogSvc.SetBypassOutOfScopeRequests(false) - svc.reqLogSvc.SetFindReqsFilter(reqlog.FindRequestsFilter{}) + svc.reqLogSvc.SetRequestLogsFilter(nil) svc.interceptSvc.UpdateSettings(intercept.Settings{ RequestsEnabled: false, ResponsesEnabled: false, RequestFilter: nil, ResponseFilter: nil, }) - svc.senderSvc.SetActiveProjectID(ulid.ULID{}) - svc.senderSvc.SetFindReqsFilter(sender.FindRequestsFilter{}) + svc.senderSvc.SetActiveProjectID("") svc.scope.SetRules(nil) - return nil + return &connect.Response[CloseProjectResponse]{}, nil } // DeleteProject removes a project from the repository. -func (svc *Service) DeleteProject(ctx context.Context, projectID ulid.ULID) error { - if svc.activeProjectID.Compare(projectID) == 0 { - return fmt.Errorf("proj: project (%v) is active", projectID.String()) +func (svc *Service) DeleteProject(ctx context.Context, req *connect.Request[DeleteProjectRequest]) (*connect.Response[DeleteProjectResponse], error) { + if svc.activeProjectID == "" { + return nil, connect.NewError(connect.CodeFailedPrecondition, ErrNoProject) } - if err := svc.repo.DeleteProject(ctx, projectID); err != nil { - return fmt.Errorf("proj: could not delete project: %w", err) + if err := svc.repo.DeleteProject(ctx, req.Msg.ProjectId); err != nil { + return nil, fmt.Errorf("proj: could not delete project: %w", err) } - return nil + return &connect.Response[DeleteProjectResponse]{}, nil } // OpenProject sets a project as the currently active project. -func (svc *Service) OpenProject(ctx context.Context, projectID ulid.ULID) (Project, error) { +func (svc *Service) OpenProject(ctx context.Context, req *connect.Request[OpenProjectRequest]) (*connect.Response[OpenProjectResponse], error) { svc.mu.Lock() defer svc.mu.Unlock() - project, err := svc.repo.FindProjectByID(ctx, projectID) + p, err := svc.repo.FindProjectByID(ctx, req.Msg.ProjectId) + if errors.Is(err, ErrProjectNotFound) { + return nil, connect.NewError(connect.CodeNotFound, ErrProjectNotFound) + } if err != nil { - return Project{}, fmt.Errorf("proj: failed to get project: %w", err) + return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("proj: failed to find project: %w", err)) } - svc.activeProjectID = project.ID + svc.activeProjectID = p.Id + + interceptSettings := intercept.Settings{ + RequestsEnabled: p.InterceptRequests, + ResponsesEnabled: p.InterceptResponses, + } + + if p.InterceptRequestFilterExpr != "" { + expr, err := filter.ParseQuery(p.InterceptRequestFilterExpr) + if err != nil { + return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("proj: failed to parse intercept request filter: %w", err)) + } + interceptSettings.RequestFilter = expr + } + + if p.InterceptResponseFilterExpr != "" { + expr, err := filter.ParseQuery(p.InterceptResponseFilterExpr) + if err != nil { + return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("proj: failed to parse intercept response filter: %w", err)) + } + interceptSettings.ResponseFilter = expr + } // Request log settings. - svc.reqLogSvc.SetFindReqsFilter(reqlog.FindRequestsFilter{ - ProjectID: project.ID, - OnlyInScope: project.Settings.ReqLogOnlyFindInScope, - SearchExpr: project.Settings.ReqLogSearchExpr, - }) - svc.reqLogSvc.SetBypassOutOfScopeRequests(project.Settings.ReqLogBypassOutOfScope) - svc.reqLogSvc.SetActiveProjectID(project.ID) + svc.reqLogSvc.SetActiveProjectID(p.Id) + svc.reqLogSvc.SetBypassOutOfScopeRequests(p.ReqLogBypassOutOfScope) + svc.reqLogSvc.SetRequestLogsFilter(p.ReqLogFilter) // Intercept settings. - svc.interceptSvc.UpdateSettings(intercept.Settings{ - RequestsEnabled: project.Settings.InterceptRequests, - ResponsesEnabled: project.Settings.InterceptResponses, - RequestFilter: project.Settings.InterceptRequestFilter, - ResponseFilter: project.Settings.InterceptResponseFilter, - }) + svc.interceptSvc.UpdateSettings(interceptSettings) // Sender settings. - svc.senderSvc.SetActiveProjectID(project.ID) - svc.senderSvc.SetFindReqsFilter(sender.FindRequestsFilter{ - ProjectID: project.ID, - OnlyInScope: project.Settings.SenderOnlyFindInScope, - SearchExpr: project.Settings.SenderSearchExpr, + svc.senderSvc.SetActiveProjectID(p.Id) + svc.senderSvc.SetRequestsFilter(&sender.RequestsFilter{ + OnlyInScope: p.SenderOnlyFindInScope, + SearchExpr: p.SenderSearchExpr, }) // Scope settings. - svc.scope.SetRules(project.Settings.ScopeRules) - - return project, nil -} - -func (svc *Service) ActiveProject(ctx context.Context) (Project, error) { - activeProjectID := svc.activeProjectID - if activeProjectID.Compare(ulid.ULID{}) == 0 { - return Project{}, ErrNoProject - } - - project, err := svc.repo.FindProjectByID(ctx, activeProjectID) + scopeRules, err := p.ParseScopeRules() if err != nil { - return Project{}, fmt.Errorf("proj: failed to get active project: %w", err) + return nil, connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("proj: failed to parse scope rules: %w", err)) + } + svc.scope.SetRules(scopeRules) + + p.IsActive = true + + return &connect.Response[OpenProjectResponse]{ + Msg: &OpenProjectResponse{ + Project: p, + }, + }, nil +} + +func (svc *Service) GetActiveProject(ctx context.Context, _ *connect.Request[GetActiveProjectRequest]) (*connect.Response[GetActiveProjectResponse], error) { + project, err := svc.activeProject(ctx) + if errors.Is(err, ErrNoProject) { + return nil, connect.NewError(connect.CodeNotFound, err) + } + if err != nil { + return nil, connect.NewError(connect.CodeInternal, err) } - project.isActive = true + project.IsActive = true + + return &connect.Response[GetActiveProjectResponse]{ + Msg: &GetActiveProjectResponse{ + Project: project, + }, + }, nil +} + +func (svc *Service) activeProject(ctx context.Context) (*Project, error) { + if svc.activeProjectID == "" { + return nil, ErrNoProject + } + + project, err := svc.repo.FindProjectByID(ctx, svc.activeProjectID) + if err != nil { + return nil, fmt.Errorf("proj: failed to get active project: %w", err) + } return project, nil } -func (svc *Service) Projects(ctx context.Context) ([]Project, error) { +func (svc *Service) ListProjects(ctx context.Context, _ *connect.Request[ListProjectsRequest]) (*connect.Response[ListProjectsResponse], error) { projects, err := svc.repo.Projects(ctx) if err != nil { return nil, fmt.Errorf("proj: could not get projects: %w", err) } - return projects, nil + for _, project := range projects { + if svc.IsProjectActive(project.Id) { + project.IsActive = true + } + } + + return &connect.Response[ListProjectsResponse]{ + Msg: &ListProjectsResponse{ + Projects: projects, + }, + }, nil } func (svc *Service) Scope() *scope.Scope { return svc.scope } -func (svc *Service) SetScopeRules(ctx context.Context, rules []scope.Rule) error { - project, err := svc.ActiveProject(ctx) +func (svc *Service) SetScopeRules(ctx context.Context, req *connect.Request[SetScopeRulesRequest]) (*connect.Response[SetScopeRulesResponse], error) { + p, err := svc.activeProject(ctx) + if errors.Is(err, ErrNoProject) { + return nil, connect.NewError(connect.CodeFailedPrecondition, err) + } + if err != nil { + return nil, connect.NewError(connect.CodeInternal, err) + } + + p.ScopeRules = req.Msg.Rules + + err = svc.repo.UpsertProject(ctx, p) + if err != nil { + return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("proj: failed to update project: %w", err)) + } + + scopeRules, err := p.ParseScopeRules() + if err != nil { + return nil, connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("proj: failed to parse scope rules: %w", err)) + } + + svc.scope.SetRules(scopeRules) + + return &connect.Response[SetScopeRulesResponse]{}, nil +} + +func (p *Project) ParseScopeRules() ([]scope.Rule, error) { + var err error + scopeRules := make([]scope.Rule, len(p.ScopeRules)) + + for i, rule := range p.ScopeRules { + scopeRules[i] = scope.Rule{} + if rule.UrlRegexp != "" { + scopeRules[i].URL, err = regexp.Compile(rule.UrlRegexp) + if err != nil { + return nil, fmt.Errorf("failed to parse scope rule's URL field: %w", err) + } + } + if rule.HeaderKeyRegexp != "" { + scopeRules[i].Header.Key, err = regexp.Compile(rule.HeaderKeyRegexp) + if err != nil { + return nil, fmt.Errorf("failed to parse scope rule's header key field: %w", err) + } + } + if rule.HeaderValueRegexp != "" { + scopeRules[i].Header.Value, err = regexp.Compile(rule.HeaderValueRegexp) + if err != nil { + return nil, fmt.Errorf("failed to parse scope rule's header value field: %w", err) + } + } + if rule.BodyRegexp != "" { + scopeRules[i].Body, err = regexp.Compile(rule.BodyRegexp) + if err != nil { + return nil, fmt.Errorf("failed to parse scope rule's body field: %w", err) + } + } + } + + return scopeRules, nil +} + +func (svc *Service) SetRequestLogsFilter(ctx context.Context, req *connect.Request[SetRequestLogsFilterRequest]) (*connect.Response[SetRequestLogsFilterResponse], error) { + project, err := svc.activeProject(ctx) + if errors.Is(err, ErrNoProject) { + return nil, connect.NewError(connect.CodeFailedPrecondition, err) + } + if err != nil { + return nil, connect.NewError(connect.CodeInternal, err) + } + + project.ReqLogFilter = req.Msg.Filter + + err = svc.repo.UpsertProject(ctx, project) + if err != nil { + return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("proj: failed to update project: %w", err)) + } + + svc.reqLogSvc.SetRequestLogsFilter(req.Msg.Filter) + + return &connect.Response[SetRequestLogsFilterResponse]{}, nil +} + +func (svc *Service) SetSenderRequestFindFilter(ctx context.Context, filter *sender.RequestsFilter) error { + project, err := svc.activeProject(ctx) if err != nil { return err } - project.Settings.ScopeRules = rules + project.SenderOnlyFindInScope = filter.OnlyInScope + project.SenderSearchExpr = filter.SearchExpr err = svc.repo.UpsertProject(ctx, project) if err != nil { return fmt.Errorf("proj: failed to update project: %w", err) } - svc.scope.SetRules(rules) + svc.senderSvc.SetRequestsFilter(filter) return nil } -func (svc *Service) SetRequestLogFindFilter(ctx context.Context, filter reqlog.FindRequestsFilter) error { - project, err := svc.ActiveProject(ctx) +func (svc *Service) IsProjectActive(projectID string) bool { + return projectID == svc.activeProjectID +} + +func (svc *Service) UpdateInterceptSettings(ctx context.Context, req *connect.Request[UpdateInterceptSettingsRequest]) (*connect.Response[UpdateInterceptSettingsResponse], error) { + project, err := svc.activeProject(ctx) if err != nil { - return err + return nil, err } - filter.ProjectID = project.ID - - project.Settings.ReqLogOnlyFindInScope = filter.OnlyInScope - project.Settings.ReqLogSearchExpr = filter.SearchExpr + project.InterceptRequests = req.Msg.RequestsEnabled + project.InterceptResponses = req.Msg.ResponsesEnabled + project.InterceptRequestFilterExpr = req.Msg.RequestFilterExpr + project.InterceptResponseFilterExpr = req.Msg.ResponseFilterExpr err = svc.repo.UpsertProject(ctx, project) if err != nil { - return fmt.Errorf("proj: failed to update project: %w", err) + return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("proj: failed to update project: %w", err)) } - svc.reqLogSvc.SetFindReqsFilter(filter) - - return nil -} - -func (svc *Service) SetSenderRequestFindFilter(ctx context.Context, filter sender.FindRequestsFilter) error { - project, err := svc.ActiveProject(ctx) + reqFilterExpr, err := filter.ParseQuery(req.Msg.RequestFilterExpr) if err != nil { - return err + return nil, connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("proj: failed to parse intercept request filter: %w", err)) } - filter.ProjectID = project.ID - - project.Settings.SenderOnlyFindInScope = filter.OnlyInScope - project.Settings.SenderSearchExpr = filter.SearchExpr - - err = svc.repo.UpsertProject(ctx, project) + respFilterExpr, err := filter.ParseQuery(req.Msg.ResponseFilterExpr) if err != nil { - return fmt.Errorf("proj: failed to update project: %w", err) + return nil, connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("proj: failed to parse intercept response filter: %w", err)) } - svc.senderSvc.SetFindReqsFilter(filter) + svc.interceptSvc.UpdateSettings(intercept.Settings{ + RequestsEnabled: req.Msg.RequestsEnabled, + ResponsesEnabled: req.Msg.ResponsesEnabled, + RequestFilter: reqFilterExpr, + ResponseFilter: respFilterExpr, + }) - return nil -} - -func (svc *Service) IsProjectActive(projectID ulid.ULID) bool { - return projectID.Compare(svc.activeProjectID) == 0 -} - -func (svc *Service) UpdateInterceptSettings(ctx context.Context, settings intercept.Settings) error { - project, err := svc.ActiveProject(ctx) - if err != nil { - return err - } - - project.Settings.InterceptRequests = settings.RequestsEnabled - project.Settings.InterceptResponses = settings.ResponsesEnabled - project.Settings.InterceptRequestFilter = settings.RequestFilter - project.Settings.InterceptResponseFilter = settings.ResponseFilter - - err = svc.repo.UpsertProject(ctx, project) - if err != nil { - return fmt.Errorf("proj: failed to update project: %w", err) - } - - svc.interceptSvc.UpdateSettings(settings) - - return nil + return &connect.Response[UpdateInterceptSettingsResponse]{}, nil } diff --git a/pkg/proj/proj.pb.go b/pkg/proj/proj.pb.go new file mode 100644 index 0000000..ef09c1b --- /dev/null +++ b/pkg/proj/proj.pb.go @@ -0,0 +1,1181 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.3 +// protoc (unknown) +// source: proj/proj.proto + +package proj + +import ( + reqlog "github.com/dstotijn/hetty/pkg/reqlog" + scope "github.com/dstotijn/hetty/pkg/scope" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Project struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + IsActive bool `protobuf:"varint,3,opt,name=is_active,json=isActive,proto3" json:"is_active,omitempty"` + // Request log settings + ReqLogBypassOutOfScope bool `protobuf:"varint,4,opt,name=req_log_bypass_out_of_scope,json=reqLogBypassOutOfScope,proto3" json:"req_log_bypass_out_of_scope,omitempty"` + // Request logs filter + ReqLogFilter *reqlog.RequestLogsFilter `protobuf:"bytes,5,opt,name=req_log_filter,json=reqLogFilter,proto3" json:"req_log_filter,omitempty"` + // Intercept settings + InterceptRequests bool `protobuf:"varint,6,opt,name=intercept_requests,json=interceptRequests,proto3" json:"intercept_requests,omitempty"` + InterceptResponses bool `protobuf:"varint,7,opt,name=intercept_responses,json=interceptResponses,proto3" json:"intercept_responses,omitempty"` + InterceptRequestFilterExpr string `protobuf:"bytes,8,opt,name=intercept_request_filter_expr,json=interceptRequestFilterExpr,proto3" json:"intercept_request_filter_expr,omitempty"` + InterceptResponseFilterExpr string `protobuf:"bytes,9,opt,name=intercept_response_filter_expr,json=interceptResponseFilterExpr,proto3" json:"intercept_response_filter_expr,omitempty"` + // Sender settings + SenderOnlyFindInScope bool `protobuf:"varint,10,opt,name=sender_only_find_in_scope,json=senderOnlyFindInScope,proto3" json:"sender_only_find_in_scope,omitempty"` + SenderSearchExpr string `protobuf:"bytes,11,opt,name=sender_search_expr,json=senderSearchExpr,proto3" json:"sender_search_expr,omitempty"` + // Scope settings + ScopeRules []*scope.ScopeRule `protobuf:"bytes,12,rep,name=scope_rules,json=scopeRules,proto3" json:"scope_rules,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Project) Reset() { + *x = Project{} + mi := &file_proj_proj_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Project) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Project) ProtoMessage() {} + +func (x *Project) ProtoReflect() protoreflect.Message { + mi := &file_proj_proj_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Project.ProtoReflect.Descriptor instead. +func (*Project) Descriptor() ([]byte, []int) { + return file_proj_proj_proto_rawDescGZIP(), []int{0} +} + +func (x *Project) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *Project) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Project) GetIsActive() bool { + if x != nil { + return x.IsActive + } + return false +} + +func (x *Project) GetReqLogBypassOutOfScope() bool { + if x != nil { + return x.ReqLogBypassOutOfScope + } + return false +} + +func (x *Project) GetReqLogFilter() *reqlog.RequestLogsFilter { + if x != nil { + return x.ReqLogFilter + } + return nil +} + +func (x *Project) GetInterceptRequests() bool { + if x != nil { + return x.InterceptRequests + } + return false +} + +func (x *Project) GetInterceptResponses() bool { + if x != nil { + return x.InterceptResponses + } + return false +} + +func (x *Project) GetInterceptRequestFilterExpr() string { + if x != nil { + return x.InterceptRequestFilterExpr + } + return "" +} + +func (x *Project) GetInterceptResponseFilterExpr() string { + if x != nil { + return x.InterceptResponseFilterExpr + } + return "" +} + +func (x *Project) GetSenderOnlyFindInScope() bool { + if x != nil { + return x.SenderOnlyFindInScope + } + return false +} + +func (x *Project) GetSenderSearchExpr() string { + if x != nil { + return x.SenderSearchExpr + } + return "" +} + +func (x *Project) GetScopeRules() []*scope.ScopeRule { + if x != nil { + return x.ScopeRules + } + return nil +} + +type CreateProjectRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateProjectRequest) Reset() { + *x = CreateProjectRequest{} + mi := &file_proj_proj_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateProjectRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateProjectRequest) ProtoMessage() {} + +func (x *CreateProjectRequest) ProtoReflect() protoreflect.Message { + mi := &file_proj_proj_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateProjectRequest.ProtoReflect.Descriptor instead. +func (*CreateProjectRequest) Descriptor() ([]byte, []int) { + return file_proj_proj_proto_rawDescGZIP(), []int{1} +} + +func (x *CreateProjectRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +type CreateProjectResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Project *Project `protobuf:"bytes,1,opt,name=project,proto3" json:"project,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateProjectResponse) Reset() { + *x = CreateProjectResponse{} + mi := &file_proj_proj_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateProjectResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateProjectResponse) ProtoMessage() {} + +func (x *CreateProjectResponse) ProtoReflect() protoreflect.Message { + mi := &file_proj_proj_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateProjectResponse.ProtoReflect.Descriptor instead. +func (*CreateProjectResponse) Descriptor() ([]byte, []int) { + return file_proj_proj_proto_rawDescGZIP(), []int{2} +} + +func (x *CreateProjectResponse) GetProject() *Project { + if x != nil { + return x.Project + } + return nil +} + +type OpenProjectRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + ProjectId string `protobuf:"bytes,1,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *OpenProjectRequest) Reset() { + *x = OpenProjectRequest{} + mi := &file_proj_proj_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *OpenProjectRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OpenProjectRequest) ProtoMessage() {} + +func (x *OpenProjectRequest) ProtoReflect() protoreflect.Message { + mi := &file_proj_proj_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use OpenProjectRequest.ProtoReflect.Descriptor instead. +func (*OpenProjectRequest) Descriptor() ([]byte, []int) { + return file_proj_proj_proto_rawDescGZIP(), []int{3} +} + +func (x *OpenProjectRequest) GetProjectId() string { + if x != nil { + return x.ProjectId + } + return "" +} + +type OpenProjectResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Project *Project `protobuf:"bytes,1,opt,name=project,proto3" json:"project,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *OpenProjectResponse) Reset() { + *x = OpenProjectResponse{} + mi := &file_proj_proj_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *OpenProjectResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OpenProjectResponse) ProtoMessage() {} + +func (x *OpenProjectResponse) ProtoReflect() protoreflect.Message { + mi := &file_proj_proj_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use OpenProjectResponse.ProtoReflect.Descriptor instead. +func (*OpenProjectResponse) Descriptor() ([]byte, []int) { + return file_proj_proj_proto_rawDescGZIP(), []int{4} +} + +func (x *OpenProjectResponse) GetProject() *Project { + if x != nil { + return x.Project + } + return nil +} + +type CloseProjectRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CloseProjectRequest) Reset() { + *x = CloseProjectRequest{} + mi := &file_proj_proj_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CloseProjectRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CloseProjectRequest) ProtoMessage() {} + +func (x *CloseProjectRequest) ProtoReflect() protoreflect.Message { + mi := &file_proj_proj_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CloseProjectRequest.ProtoReflect.Descriptor instead. +func (*CloseProjectRequest) Descriptor() ([]byte, []int) { + return file_proj_proj_proto_rawDescGZIP(), []int{5} +} + +type CloseProjectResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CloseProjectResponse) Reset() { + *x = CloseProjectResponse{} + mi := &file_proj_proj_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CloseProjectResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CloseProjectResponse) ProtoMessage() {} + +func (x *CloseProjectResponse) ProtoReflect() protoreflect.Message { + mi := &file_proj_proj_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CloseProjectResponse.ProtoReflect.Descriptor instead. +func (*CloseProjectResponse) Descriptor() ([]byte, []int) { + return file_proj_proj_proto_rawDescGZIP(), []int{6} +} + +type DeleteProjectRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + ProjectId string `protobuf:"bytes,1,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteProjectRequest) Reset() { + *x = DeleteProjectRequest{} + mi := &file_proj_proj_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteProjectRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteProjectRequest) ProtoMessage() {} + +func (x *DeleteProjectRequest) ProtoReflect() protoreflect.Message { + mi := &file_proj_proj_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteProjectRequest.ProtoReflect.Descriptor instead. +func (*DeleteProjectRequest) Descriptor() ([]byte, []int) { + return file_proj_proj_proto_rawDescGZIP(), []int{7} +} + +func (x *DeleteProjectRequest) GetProjectId() string { + if x != nil { + return x.ProjectId + } + return "" +} + +type DeleteProjectResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteProjectResponse) Reset() { + *x = DeleteProjectResponse{} + mi := &file_proj_proj_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteProjectResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteProjectResponse) ProtoMessage() {} + +func (x *DeleteProjectResponse) ProtoReflect() protoreflect.Message { + mi := &file_proj_proj_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteProjectResponse.ProtoReflect.Descriptor instead. +func (*DeleteProjectResponse) Descriptor() ([]byte, []int) { + return file_proj_proj_proto_rawDescGZIP(), []int{8} +} + +type GetActiveProjectRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetActiveProjectRequest) Reset() { + *x = GetActiveProjectRequest{} + mi := &file_proj_proj_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetActiveProjectRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetActiveProjectRequest) ProtoMessage() {} + +func (x *GetActiveProjectRequest) ProtoReflect() protoreflect.Message { + mi := &file_proj_proj_proto_msgTypes[9] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetActiveProjectRequest.ProtoReflect.Descriptor instead. +func (*GetActiveProjectRequest) Descriptor() ([]byte, []int) { + return file_proj_proj_proto_rawDescGZIP(), []int{9} +} + +type GetActiveProjectResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Project *Project `protobuf:"bytes,1,opt,name=project,proto3" json:"project,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetActiveProjectResponse) Reset() { + *x = GetActiveProjectResponse{} + mi := &file_proj_proj_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetActiveProjectResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetActiveProjectResponse) ProtoMessage() {} + +func (x *GetActiveProjectResponse) ProtoReflect() protoreflect.Message { + mi := &file_proj_proj_proto_msgTypes[10] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetActiveProjectResponse.ProtoReflect.Descriptor instead. +func (*GetActiveProjectResponse) Descriptor() ([]byte, []int) { + return file_proj_proj_proto_rawDescGZIP(), []int{10} +} + +func (x *GetActiveProjectResponse) GetProject() *Project { + if x != nil { + return x.Project + } + return nil +} + +type ListProjectsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListProjectsRequest) Reset() { + *x = ListProjectsRequest{} + mi := &file_proj_proj_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListProjectsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListProjectsRequest) ProtoMessage() {} + +func (x *ListProjectsRequest) ProtoReflect() protoreflect.Message { + mi := &file_proj_proj_proto_msgTypes[11] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListProjectsRequest.ProtoReflect.Descriptor instead. +func (*ListProjectsRequest) Descriptor() ([]byte, []int) { + return file_proj_proj_proto_rawDescGZIP(), []int{11} +} + +type ListProjectsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Projects []*Project `protobuf:"bytes,1,rep,name=projects,proto3" json:"projects,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListProjectsResponse) Reset() { + *x = ListProjectsResponse{} + mi := &file_proj_proj_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListProjectsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListProjectsResponse) ProtoMessage() {} + +func (x *ListProjectsResponse) ProtoReflect() protoreflect.Message { + mi := &file_proj_proj_proto_msgTypes[12] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListProjectsResponse.ProtoReflect.Descriptor instead. +func (*ListProjectsResponse) Descriptor() ([]byte, []int) { + return file_proj_proj_proto_rawDescGZIP(), []int{12} +} + +func (x *ListProjectsResponse) GetProjects() []*Project { + if x != nil { + return x.Projects + } + return nil +} + +type UpdateInterceptSettingsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + RequestsEnabled bool `protobuf:"varint,1,opt,name=requests_enabled,json=requestsEnabled,proto3" json:"requests_enabled,omitempty"` + ResponsesEnabled bool `protobuf:"varint,2,opt,name=responses_enabled,json=responsesEnabled,proto3" json:"responses_enabled,omitempty"` + RequestFilterExpr string `protobuf:"bytes,3,opt,name=request_filter_expr,json=requestFilterExpr,proto3" json:"request_filter_expr,omitempty"` + ResponseFilterExpr string `protobuf:"bytes,4,opt,name=response_filter_expr,json=responseFilterExpr,proto3" json:"response_filter_expr,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateInterceptSettingsRequest) Reset() { + *x = UpdateInterceptSettingsRequest{} + mi := &file_proj_proj_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateInterceptSettingsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateInterceptSettingsRequest) ProtoMessage() {} + +func (x *UpdateInterceptSettingsRequest) ProtoReflect() protoreflect.Message { + mi := &file_proj_proj_proto_msgTypes[13] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateInterceptSettingsRequest.ProtoReflect.Descriptor instead. +func (*UpdateInterceptSettingsRequest) Descriptor() ([]byte, []int) { + return file_proj_proj_proto_rawDescGZIP(), []int{13} +} + +func (x *UpdateInterceptSettingsRequest) GetRequestsEnabled() bool { + if x != nil { + return x.RequestsEnabled + } + return false +} + +func (x *UpdateInterceptSettingsRequest) GetResponsesEnabled() bool { + if x != nil { + return x.ResponsesEnabled + } + return false +} + +func (x *UpdateInterceptSettingsRequest) GetRequestFilterExpr() string { + if x != nil { + return x.RequestFilterExpr + } + return "" +} + +func (x *UpdateInterceptSettingsRequest) GetResponseFilterExpr() string { + if x != nil { + return x.ResponseFilterExpr + } + return "" +} + +type UpdateInterceptSettingsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateInterceptSettingsResponse) Reset() { + *x = UpdateInterceptSettingsResponse{} + mi := &file_proj_proj_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateInterceptSettingsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateInterceptSettingsResponse) ProtoMessage() {} + +func (x *UpdateInterceptSettingsResponse) ProtoReflect() protoreflect.Message { + mi := &file_proj_proj_proto_msgTypes[14] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateInterceptSettingsResponse.ProtoReflect.Descriptor instead. +func (*UpdateInterceptSettingsResponse) Descriptor() ([]byte, []int) { + return file_proj_proj_proto_rawDescGZIP(), []int{14} +} + +type SetScopeRulesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Rules []*scope.ScopeRule `protobuf:"bytes,1,rep,name=rules,proto3" json:"rules,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SetScopeRulesRequest) Reset() { + *x = SetScopeRulesRequest{} + mi := &file_proj_proj_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SetScopeRulesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SetScopeRulesRequest) ProtoMessage() {} + +func (x *SetScopeRulesRequest) ProtoReflect() protoreflect.Message { + mi := &file_proj_proj_proto_msgTypes[15] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SetScopeRulesRequest.ProtoReflect.Descriptor instead. +func (*SetScopeRulesRequest) Descriptor() ([]byte, []int) { + return file_proj_proj_proto_rawDescGZIP(), []int{15} +} + +func (x *SetScopeRulesRequest) GetRules() []*scope.ScopeRule { + if x != nil { + return x.Rules + } + return nil +} + +type SetScopeRulesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SetScopeRulesResponse) Reset() { + *x = SetScopeRulesResponse{} + mi := &file_proj_proj_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SetScopeRulesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SetScopeRulesResponse) ProtoMessage() {} + +func (x *SetScopeRulesResponse) ProtoReflect() protoreflect.Message { + mi := &file_proj_proj_proto_msgTypes[16] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SetScopeRulesResponse.ProtoReflect.Descriptor instead. +func (*SetScopeRulesResponse) Descriptor() ([]byte, []int) { + return file_proj_proj_proto_rawDescGZIP(), []int{16} +} + +type SetRequestLogsFilterRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Filter *reqlog.RequestLogsFilter `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SetRequestLogsFilterRequest) Reset() { + *x = SetRequestLogsFilterRequest{} + mi := &file_proj_proj_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SetRequestLogsFilterRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SetRequestLogsFilterRequest) ProtoMessage() {} + +func (x *SetRequestLogsFilterRequest) ProtoReflect() protoreflect.Message { + mi := &file_proj_proj_proto_msgTypes[17] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SetRequestLogsFilterRequest.ProtoReflect.Descriptor instead. +func (*SetRequestLogsFilterRequest) Descriptor() ([]byte, []int) { + return file_proj_proj_proto_rawDescGZIP(), []int{17} +} + +func (x *SetRequestLogsFilterRequest) GetFilter() *reqlog.RequestLogsFilter { + if x != nil { + return x.Filter + } + return nil +} + +type SetRequestLogsFilterResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SetRequestLogsFilterResponse) Reset() { + *x = SetRequestLogsFilterResponse{} + mi := &file_proj_proj_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SetRequestLogsFilterResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SetRequestLogsFilterResponse) ProtoMessage() {} + +func (x *SetRequestLogsFilterResponse) ProtoReflect() protoreflect.Message { + mi := &file_proj_proj_proto_msgTypes[18] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SetRequestLogsFilterResponse.ProtoReflect.Descriptor instead. +func (*SetRequestLogsFilterResponse) Descriptor() ([]byte, []int) { + return file_proj_proj_proto_rawDescGZIP(), []int{18} +} + +var File_proj_proj_proto protoreflect.FileDescriptor + +var file_proj_proj_proto_rawDesc = []byte{ + 0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x6a, 0x2f, 0x70, 0x72, 0x6f, 0x6a, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x0d, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x2e, 0x76, 0x31, + 0x1a, 0x13, 0x72, 0x65, 0x71, 0x6c, 0x6f, 0x67, 0x2f, 0x72, 0x65, 0x71, 0x6c, 0x6f, 0x67, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x11, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x2f, 0x73, 0x63, 0x6f, + 0x70, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xdd, 0x04, 0x0a, 0x07, 0x50, 0x72, 0x6f, + 0x6a, 0x65, 0x63, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x73, 0x5f, 0x61, + 0x63, 0x74, 0x69, 0x76, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x41, + 0x63, 0x74, 0x69, 0x76, 0x65, 0x12, 0x3b, 0x0a, 0x1b, 0x72, 0x65, 0x71, 0x5f, 0x6c, 0x6f, 0x67, + 0x5f, 0x62, 0x79, 0x70, 0x61, 0x73, 0x73, 0x5f, 0x6f, 0x75, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x73, + 0x63, 0x6f, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, 0x72, 0x65, 0x71, 0x4c, + 0x6f, 0x67, 0x42, 0x79, 0x70, 0x61, 0x73, 0x73, 0x4f, 0x75, 0x74, 0x4f, 0x66, 0x53, 0x63, 0x6f, + 0x70, 0x65, 0x12, 0x48, 0x0a, 0x0e, 0x72, 0x65, 0x71, 0x5f, 0x6c, 0x6f, 0x67, 0x5f, 0x66, 0x69, + 0x6c, 0x74, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x68, 0x65, 0x74, + 0x74, 0x79, 0x2e, 0x72, 0x65, 0x71, 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x0c, + 0x72, 0x65, 0x71, 0x4c, 0x6f, 0x67, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x2d, 0x0a, 0x12, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x65, 0x70, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, + 0x65, 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x12, 0x2f, 0x0a, 0x13, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x63, 0x65, 0x70, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, + 0x65, 0x70, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x12, 0x41, 0x0a, 0x1d, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x65, 0x70, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x5f, 0x65, 0x78, 0x70, 0x72, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x1a, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x65, 0x70, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x45, 0x78, 0x70, 0x72, 0x12, + 0x43, 0x0a, 0x1e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x65, 0x70, 0x74, 0x5f, 0x72, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x5f, 0x65, 0x78, 0x70, + 0x72, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x1b, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x65, + 0x70, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, + 0x45, 0x78, 0x70, 0x72, 0x12, 0x38, 0x0a, 0x19, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x5f, 0x6f, + 0x6e, 0x6c, 0x79, 0x5f, 0x66, 0x69, 0x6e, 0x64, 0x5f, 0x69, 0x6e, 0x5f, 0x73, 0x63, 0x6f, 0x70, + 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x15, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x4f, + 0x6e, 0x6c, 0x79, 0x46, 0x69, 0x6e, 0x64, 0x49, 0x6e, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x12, 0x2c, + 0x0a, 0x12, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x5f, + 0x65, 0x78, 0x70, 0x72, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x73, 0x65, 0x6e, 0x64, + 0x65, 0x72, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x45, 0x78, 0x70, 0x72, 0x12, 0x3a, 0x0a, 0x0b, + 0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x19, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x2e, + 0x76, 0x31, 0x2e, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x0a, 0x73, 0x63, + 0x6f, 0x70, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x22, 0x2a, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x49, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, + 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, + 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x2e, 0x76, 0x31, 0x2e, 0x50, + 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x22, + 0x33, 0x0a, 0x12, 0x4f, 0x70, 0x65, 0x6e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, + 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x6a, 0x65, + 0x63, 0x74, 0x49, 0x64, 0x22, 0x47, 0x0a, 0x13, 0x4f, 0x70, 0x65, 0x6e, 0x50, 0x72, 0x6f, 0x6a, + 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x07, 0x70, + 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x68, + 0x65, 0x74, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, + 0x6a, 0x65, 0x63, 0x74, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x22, 0x15, 0x0a, + 0x13, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x22, 0x16, 0x0a, 0x14, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x50, 0x72, 0x6f, + 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x35, 0x0a, 0x14, + 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, + 0x74, 0x49, 0x64, 0x22, 0x17, 0x0a, 0x15, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x72, 0x6f, + 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x0a, 0x17, + 0x47, 0x65, 0x74, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x4c, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x41, 0x63, + 0x74, 0x69, 0x76, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, + 0x6a, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x07, 0x70, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x22, 0x15, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f, + 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x4a, 0x0a, 0x14, + 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x70, + 0x72, 0x6f, 0x6a, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x08, + 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0xda, 0x01, 0x0a, 0x1e, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x65, 0x70, 0x74, 0x53, 0x65, 0x74, 0x74, + 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x29, 0x0a, 0x10, 0x72, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x45, + 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x2b, 0x0a, 0x11, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x73, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x10, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x45, 0x6e, 0x61, 0x62, + 0x6c, 0x65, 0x64, 0x12, 0x2e, 0x0a, 0x13, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x66, + 0x69, 0x6c, 0x74, 0x65, 0x72, 0x5f, 0x65, 0x78, 0x70, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x11, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x45, + 0x78, 0x70, 0x72, 0x12, 0x30, 0x0a, 0x14, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, + 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x5f, 0x65, 0x78, 0x70, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x12, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, + 0x72, 0x45, 0x78, 0x70, 0x72, 0x22, 0x21, 0x0a, 0x1f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, + 0x6e, 0x74, 0x65, 0x72, 0x63, 0x65, 0x70, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x47, 0x0a, 0x14, 0x53, 0x65, 0x74, 0x53, + 0x63, 0x6f, 0x70, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x2f, 0x0a, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x19, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x05, 0x72, 0x75, 0x6c, 0x65, + 0x73, 0x22, 0x17, 0x0a, 0x15, 0x53, 0x65, 0x74, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x52, 0x75, 0x6c, + 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x59, 0x0a, 0x1b, 0x53, 0x65, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x46, 0x69, 0x6c, 0x74, + 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3a, 0x0a, 0x06, 0x66, 0x69, 0x6c, + 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x68, 0x65, 0x74, 0x74, + 0x79, 0x2e, 0x72, 0x65, 0x71, 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x06, 0x66, + 0x69, 0x6c, 0x74, 0x65, 0x72, 0x22, 0x1e, 0x0a, 0x1c, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x8e, 0x07, 0x0a, 0x0e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, + 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5c, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x23, 0x2e, 0x68, 0x65, 0x74, 0x74, + 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, + 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x2e, 0x76, 0x31, 0x2e, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x56, 0x0a, 0x0b, 0x4f, 0x70, 0x65, 0x6e, 0x50, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x21, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x70, 0x72, + 0x6f, 0x6a, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x70, 0x65, 0x6e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, + 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x70, 0x65, 0x6e, 0x50, 0x72, 0x6f, + 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x59, + 0x0a, 0x0c, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x22, + 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x2e, 0x76, 0x31, 0x2e, 0x43, + 0x6c, 0x6f, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x2e, + 0x76, 0x31, 0x2e, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5c, 0x0a, 0x0d, 0x44, 0x65, 0x6c, + 0x65, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x23, 0x2e, 0x68, 0x65, 0x74, + 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x24, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x2e, 0x76, 0x31, 0x2e, + 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x65, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x41, 0x63, + 0x74, 0x69, 0x76, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x26, 0x2e, 0x68, 0x65, + 0x74, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x41, + 0x63, 0x74, 0x69, 0x76, 0x65, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x6a, + 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x50, 0x72, 0x6f, + 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x59, + 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x22, + 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x2e, 0x76, 0x31, 0x2e, 0x4c, + 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x2e, + 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x7a, 0x0a, 0x17, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x65, 0x70, 0x74, 0x53, 0x65, 0x74, 0x74, + 0x69, 0x6e, 0x67, 0x73, 0x12, 0x2d, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, + 0x6a, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, + 0x63, 0x65, 0x70, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x6a, + 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x63, + 0x65, 0x70, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5c, 0x0a, 0x0d, 0x53, 0x65, 0x74, 0x53, 0x63, 0x6f, 0x70, + 0x65, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x23, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x70, + 0x72, 0x6f, 0x6a, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x52, + 0x75, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x68, 0x65, + 0x74, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x53, + 0x63, 0x6f, 0x70, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x71, 0x0a, 0x14, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x2a, 0x2e, 0x68, 0x65, + 0x74, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, + 0x70, 0x72, 0x6f, 0x6a, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x24, 0x5a, 0x22, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x73, 0x74, 0x6f, 0x74, 0x69, 0x6a, 0x6e, 0x2f, 0x68, 0x65, + 0x74, 0x74, 0x79, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x6a, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_proj_proj_proto_rawDescOnce sync.Once + file_proj_proj_proto_rawDescData = file_proj_proj_proto_rawDesc +) + +func file_proj_proj_proto_rawDescGZIP() []byte { + file_proj_proj_proto_rawDescOnce.Do(func() { + file_proj_proj_proto_rawDescData = protoimpl.X.CompressGZIP(file_proj_proj_proto_rawDescData) + }) + return file_proj_proj_proto_rawDescData +} + +var file_proj_proj_proto_msgTypes = make([]protoimpl.MessageInfo, 19) +var file_proj_proj_proto_goTypes = []any{ + (*Project)(nil), // 0: hetty.proj.v1.Project + (*CreateProjectRequest)(nil), // 1: hetty.proj.v1.CreateProjectRequest + (*CreateProjectResponse)(nil), // 2: hetty.proj.v1.CreateProjectResponse + (*OpenProjectRequest)(nil), // 3: hetty.proj.v1.OpenProjectRequest + (*OpenProjectResponse)(nil), // 4: hetty.proj.v1.OpenProjectResponse + (*CloseProjectRequest)(nil), // 5: hetty.proj.v1.CloseProjectRequest + (*CloseProjectResponse)(nil), // 6: hetty.proj.v1.CloseProjectResponse + (*DeleteProjectRequest)(nil), // 7: hetty.proj.v1.DeleteProjectRequest + (*DeleteProjectResponse)(nil), // 8: hetty.proj.v1.DeleteProjectResponse + (*GetActiveProjectRequest)(nil), // 9: hetty.proj.v1.GetActiveProjectRequest + (*GetActiveProjectResponse)(nil), // 10: hetty.proj.v1.GetActiveProjectResponse + (*ListProjectsRequest)(nil), // 11: hetty.proj.v1.ListProjectsRequest + (*ListProjectsResponse)(nil), // 12: hetty.proj.v1.ListProjectsResponse + (*UpdateInterceptSettingsRequest)(nil), // 13: hetty.proj.v1.UpdateInterceptSettingsRequest + (*UpdateInterceptSettingsResponse)(nil), // 14: hetty.proj.v1.UpdateInterceptSettingsResponse + (*SetScopeRulesRequest)(nil), // 15: hetty.proj.v1.SetScopeRulesRequest + (*SetScopeRulesResponse)(nil), // 16: hetty.proj.v1.SetScopeRulesResponse + (*SetRequestLogsFilterRequest)(nil), // 17: hetty.proj.v1.SetRequestLogsFilterRequest + (*SetRequestLogsFilterResponse)(nil), // 18: hetty.proj.v1.SetRequestLogsFilterResponse + (*reqlog.RequestLogsFilter)(nil), // 19: hetty.reqlog.v1.RequestLogsFilter + (*scope.ScopeRule)(nil), // 20: hetty.scope.v1.ScopeRule +} +var file_proj_proj_proto_depIdxs = []int32{ + 19, // 0: hetty.proj.v1.Project.req_log_filter:type_name -> hetty.reqlog.v1.RequestLogsFilter + 20, // 1: hetty.proj.v1.Project.scope_rules:type_name -> hetty.scope.v1.ScopeRule + 0, // 2: hetty.proj.v1.CreateProjectResponse.project:type_name -> hetty.proj.v1.Project + 0, // 3: hetty.proj.v1.OpenProjectResponse.project:type_name -> hetty.proj.v1.Project + 0, // 4: hetty.proj.v1.GetActiveProjectResponse.project:type_name -> hetty.proj.v1.Project + 0, // 5: hetty.proj.v1.ListProjectsResponse.projects:type_name -> hetty.proj.v1.Project + 20, // 6: hetty.proj.v1.SetScopeRulesRequest.rules:type_name -> hetty.scope.v1.ScopeRule + 19, // 7: hetty.proj.v1.SetRequestLogsFilterRequest.filter:type_name -> hetty.reqlog.v1.RequestLogsFilter + 1, // 8: hetty.proj.v1.ProjectService.CreateProject:input_type -> hetty.proj.v1.CreateProjectRequest + 3, // 9: hetty.proj.v1.ProjectService.OpenProject:input_type -> hetty.proj.v1.OpenProjectRequest + 5, // 10: hetty.proj.v1.ProjectService.CloseProject:input_type -> hetty.proj.v1.CloseProjectRequest + 7, // 11: hetty.proj.v1.ProjectService.DeleteProject:input_type -> hetty.proj.v1.DeleteProjectRequest + 9, // 12: hetty.proj.v1.ProjectService.GetActiveProject:input_type -> hetty.proj.v1.GetActiveProjectRequest + 11, // 13: hetty.proj.v1.ProjectService.ListProjects:input_type -> hetty.proj.v1.ListProjectsRequest + 13, // 14: hetty.proj.v1.ProjectService.UpdateInterceptSettings:input_type -> hetty.proj.v1.UpdateInterceptSettingsRequest + 15, // 15: hetty.proj.v1.ProjectService.SetScopeRules:input_type -> hetty.proj.v1.SetScopeRulesRequest + 17, // 16: hetty.proj.v1.ProjectService.SetRequestLogsFilter:input_type -> hetty.proj.v1.SetRequestLogsFilterRequest + 2, // 17: hetty.proj.v1.ProjectService.CreateProject:output_type -> hetty.proj.v1.CreateProjectResponse + 4, // 18: hetty.proj.v1.ProjectService.OpenProject:output_type -> hetty.proj.v1.OpenProjectResponse + 6, // 19: hetty.proj.v1.ProjectService.CloseProject:output_type -> hetty.proj.v1.CloseProjectResponse + 8, // 20: hetty.proj.v1.ProjectService.DeleteProject:output_type -> hetty.proj.v1.DeleteProjectResponse + 10, // 21: hetty.proj.v1.ProjectService.GetActiveProject:output_type -> hetty.proj.v1.GetActiveProjectResponse + 12, // 22: hetty.proj.v1.ProjectService.ListProjects:output_type -> hetty.proj.v1.ListProjectsResponse + 14, // 23: hetty.proj.v1.ProjectService.UpdateInterceptSettings:output_type -> hetty.proj.v1.UpdateInterceptSettingsResponse + 16, // 24: hetty.proj.v1.ProjectService.SetScopeRules:output_type -> hetty.proj.v1.SetScopeRulesResponse + 18, // 25: hetty.proj.v1.ProjectService.SetRequestLogsFilter:output_type -> hetty.proj.v1.SetRequestLogsFilterResponse + 17, // [17:26] is the sub-list for method output_type + 8, // [8:17] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name +} + +func init() { file_proj_proj_proto_init() } +func file_proj_proj_proto_init() { + if File_proj_proj_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_proj_proj_proto_rawDesc, + NumEnums: 0, + NumMessages: 19, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_proj_proj_proto_goTypes, + DependencyIndexes: file_proj_proj_proto_depIdxs, + MessageInfos: file_proj_proj_proto_msgTypes, + }.Build() + File_proj_proj_proto = out.File + file_proj_proj_proto_rawDesc = nil + file_proj_proj_proto_goTypes = nil + file_proj_proj_proto_depIdxs = nil +} diff --git a/pkg/proj/repo.go b/pkg/proj/repo.go index 0b9cb0d..3444c34 100644 --- a/pkg/proj/repo.go +++ b/pkg/proj/repo.go @@ -2,14 +2,12 @@ package proj import ( "context" - - "github.com/oklog/ulid" ) type Repository interface { - FindProjectByID(ctx context.Context, id ulid.ULID) (Project, error) - UpsertProject(ctx context.Context, project Project) error - DeleteProject(ctx context.Context, id ulid.ULID) error - Projects(ctx context.Context) ([]Project, error) + FindProjectByID(ctx context.Context, id string) (*Project, error) + UpsertProject(ctx context.Context, project *Project) error + DeleteProject(ctx context.Context, id string) error + Projects(ctx context.Context) ([]*Project, error) Close() error } diff --git a/pkg/proxy/intercept/filter.go b/pkg/proxy/intercept/filter.go index e1cab87..1f12774 100644 --- a/pkg/proxy/intercept/filter.go +++ b/pkg/proxy/intercept/filter.go @@ -5,12 +5,12 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "strconv" "strings" "github.com/dstotijn/hetty/pkg/filter" + httppb "github.com/dstotijn/hetty/pkg/http" "github.com/dstotijn/hetty/pkg/scope" ) @@ -34,7 +34,7 @@ var reqFilterKeyFns = map[string]func(req *http.Request) (string, error){ return "", err } - req.Body = ioutil.NopCloser(bytes.NewBuffer(body)) + req.Body = io.NopCloser(bytes.NewBuffer(body)) return string(body), nil }, } @@ -61,7 +61,7 @@ var resFilterKeyFns = map[string]func(res *http.Response) (string, error){ return "", err } - res.Body = ioutil.NopCloser(bytes.NewBuffer(body)) + res.Body = io.NopCloser(bytes.NewBuffer(body)) return string(body), nil }, @@ -134,7 +134,7 @@ func matchReqInfixExpr(req *http.Request, expr filter.InfixExpression) (bool, er } if leftVal == "headers" { - match, err := filter.MatchHTTPHeaders(expr.Operator, expr.Right, req.Header) + match, err := filter.MatchHTTPHeaders(expr.Operator, expr.Right, httppb.ParseHeader(req.Header)) if err != nil { return false, fmt.Errorf("failed to match request HTTP headers: %w", err) } @@ -267,7 +267,7 @@ func MatchRequestScope(req *http.Request, s *scope.Scope) (bool, error) { return false, fmt.Errorf("failed to read request body: %w", err) } - req.Body = ioutil.NopCloser(bytes.NewBuffer(body)) + req.Body = io.NopCloser(bytes.NewBuffer(body)) if matches := rule.Body.Match(body); matches { return true, nil @@ -345,7 +345,7 @@ func matchResInfixExpr(res *http.Response, expr filter.InfixExpression) (bool, e } if leftVal == "headers" { - match, err := filter.MatchHTTPHeaders(expr.Operator, expr.Right, res.Header) + match, err := filter.MatchHTTPHeaders(expr.Operator, expr.Right, httppb.ParseHeader(res.Header)) if err != nil { return false, fmt.Errorf("failed to match request HTTP headers: %w", err) } diff --git a/pkg/proxy/intercept/intercept.go b/pkg/proxy/intercept/intercept.go index 3dd4ce6..f3d4046 100644 --- a/pkg/proxy/intercept/intercept.go +++ b/pkg/proxy/intercept/intercept.go @@ -8,7 +8,7 @@ import ( "sort" "sync" - "github.com/oklog/ulid" + "github.com/oklog/ulid/v2" "github.com/dstotijn/hetty/pkg/filter" "github.com/dstotijn/hetty/pkg/log" diff --git a/pkg/proxy/intercept/intercept_test.go b/pkg/proxy/intercept/intercept_test.go index 2652a93..3584ddd 100644 --- a/pkg/proxy/intercept/intercept_test.go +++ b/pkg/proxy/intercept/intercept_test.go @@ -3,23 +3,19 @@ package intercept_test import ( "context" "errors" - "math/rand" "net/http" "net/http/httptest" "sync" "testing" "time" - "github.com/oklog/ulid" + "github.com/oklog/ulid/v2" "go.uber.org/zap" "github.com/dstotijn/hetty/pkg/proxy" "github.com/dstotijn/hetty/pkg/proxy/intercept" ) -//nolint:gosec -var ulidEntropy = rand.New(rand.NewSource(time.Now().UnixNano())) - func TestRequestModifier(t *testing.T) { t.Parallel() @@ -33,7 +29,7 @@ func TestRequestModifier(t *testing.T) { ResponsesEnabled: false, }) - reqID := ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) + reqID := ulid.Make() err := svc.ModifyRequest(reqID, nil, nil) if !errors.Is(err, intercept.ErrRequestNotFound) { @@ -55,7 +51,7 @@ func TestRequestModifier(t *testing.T) { defer cancel() req := httptest.NewRequest("GET", "https://example.com/foo", nil) - reqID := ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) + reqID := ulid.Make() *req = *req.WithContext(ctx) *req = *req.WithContext(proxy.WithRequestID(req.Context(), reqID)) @@ -82,7 +78,7 @@ func TestRequestModifier(t *testing.T) { req := httptest.NewRequest("GET", "https://example.com/foo", nil) req.Header.Set("X-Foo", "foo") - reqID := ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) + reqID := ulid.Make() *req = *req.WithContext(proxy.WithRequestID(req.Context(), reqID)) modReq := req.Clone(context.Background()) @@ -143,7 +139,7 @@ func TestResponseModifier(t *testing.T) { ResponsesEnabled: true, }) - reqID := ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) + reqID := ulid.Make() err := svc.ModifyResponse(reqID, nil) if !errors.Is(err, intercept.ErrRequestNotFound) { @@ -165,7 +161,7 @@ func TestResponseModifier(t *testing.T) { defer cancel() req := httptest.NewRequest("GET", "https://example.com/foo", nil) - reqID := ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) + reqID := ulid.Make() *req = *req.WithContext(ctx) *req = *req.WithContext(proxy.WithRequestID(req.Context(), reqID)) @@ -212,7 +208,7 @@ func TestResponseModifier(t *testing.T) { req := httptest.NewRequest("GET", "https://example.com/foo", nil) req.Header.Set("X-Foo", "foo") - reqID := ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) + reqID := ulid.Make() *req = *req.WithContext(proxy.WithRequestID(req.Context(), reqID)) res := &http.Response{ diff --git a/pkg/proxy/proxy.go b/pkg/proxy/proxy.go index 75cb65d..f957bc4 100644 --- a/pkg/proxy/proxy.go +++ b/pkg/proxy/proxy.go @@ -7,21 +7,17 @@ import ( "crypto/x509" "errors" "fmt" - "math/rand" "net" "net/http" "net/http/httputil" "strings" "time" - "github.com/oklog/ulid" + "github.com/oklog/ulid/v2" "github.com/dstotijn/hetty/pkg/log" ) -//nolint:gosec -var ulidEntropy = rand.New(rand.NewSource(time.Now().UnixNano())) - type contextKey int const reqIDKey contextKey = 0 @@ -95,7 +91,7 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - reqID := ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) + reqID := ulid.Make() ctx := context.WithValue(r.Context(), reqIDKey, reqID) *r = *r.WithContext(ctx) diff --git a/pkg/reqlog/repo.go b/pkg/reqlog/repo.go index 282e0c0..b5c95c8 100644 --- a/pkg/reqlog/repo.go +++ b/pkg/reqlog/repo.go @@ -3,15 +3,13 @@ package reqlog import ( "context" - "github.com/oklog/ulid" - - "github.com/dstotijn/hetty/pkg/scope" + httppb "github.com/dstotijn/hetty/pkg/http" ) type Repository interface { - FindRequestLogs(ctx context.Context, filter FindRequestsFilter, scope *scope.Scope) ([]RequestLog, error) - FindRequestLogByID(ctx context.Context, projectID, id ulid.ULID) (RequestLog, error) - StoreRequestLog(ctx context.Context, reqLog RequestLog) error - StoreResponseLog(ctx context.Context, projectID, reqLogID ulid.ULID, resLog ResponseLog) error - ClearRequestLogs(ctx context.Context, projectID ulid.ULID) error + FindRequestLogs(ctx context.Context, projectID string, filterFn func(*HttpRequestLog) (bool, error)) ([]*HttpRequestLog, error) + FindRequestLogByID(ctx context.Context, projectID, id string) (*HttpRequestLog, error) + StoreRequestLog(ctx context.Context, reqLog *HttpRequestLog) error + StoreResponseLog(ctx context.Context, projectID, reqLogID string, resLog *httppb.Response) error + ClearRequestLogs(ctx context.Context, projectID string) error } diff --git a/pkg/reqlog/reqlog.connect.go b/pkg/reqlog/reqlog.connect.go new file mode 100644 index 0000000..824a7ef --- /dev/null +++ b/pkg/reqlog/reqlog.connect.go @@ -0,0 +1,167 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: reqlog/reqlog.proto + +package reqlog + +import ( + connect "connectrpc.com/connect" + context "context" + errors "errors" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion1_13_0 + +const ( + // HttpRequestLogServiceName is the fully-qualified name of the HttpRequestLogService service. + HttpRequestLogServiceName = "hetty.reqlog.v1.HttpRequestLogService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // HttpRequestLogServiceGetHttpRequestLogProcedure is the fully-qualified name of the + // HttpRequestLogService's GetHttpRequestLog RPC. + HttpRequestLogServiceGetHttpRequestLogProcedure = "/hetty.reqlog.v1.HttpRequestLogService/GetHttpRequestLog" + // HttpRequestLogServiceListHttpRequestLogsProcedure is the fully-qualified name of the + // HttpRequestLogService's ListHttpRequestLogs RPC. + HttpRequestLogServiceListHttpRequestLogsProcedure = "/hetty.reqlog.v1.HttpRequestLogService/ListHttpRequestLogs" + // HttpRequestLogServiceClearHttpRequestLogsProcedure is the fully-qualified name of the + // HttpRequestLogService's ClearHttpRequestLogs RPC. + HttpRequestLogServiceClearHttpRequestLogsProcedure = "/hetty.reqlog.v1.HttpRequestLogService/ClearHttpRequestLogs" +) + +// HttpRequestLogServiceClient is a client for the hetty.reqlog.v1.HttpRequestLogService service. +type HttpRequestLogServiceClient interface { + GetHttpRequestLog(context.Context, *connect.Request[GetHttpRequestLogRequest]) (*connect.Response[GetHttpRequestLogResponse], error) + ListHttpRequestLogs(context.Context, *connect.Request[ListHttpRequestLogsRequest]) (*connect.Response[ListHttpRequestLogsResponse], error) + ClearHttpRequestLogs(context.Context, *connect.Request[ClearHttpRequestLogsRequest]) (*connect.Response[ClearHttpRequestLogsResponse], error) +} + +// NewHttpRequestLogServiceClient constructs a client for the hetty.reqlog.v1.HttpRequestLogService +// service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for +// gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply +// the connect.WithGRPC() or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewHttpRequestLogServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) HttpRequestLogServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + httpRequestLogServiceMethods := File_reqlog_reqlog_proto.Services().ByName("HttpRequestLogService").Methods() + return &httpRequestLogServiceClient{ + getHttpRequestLog: connect.NewClient[GetHttpRequestLogRequest, GetHttpRequestLogResponse]( + httpClient, + baseURL+HttpRequestLogServiceGetHttpRequestLogProcedure, + connect.WithSchema(httpRequestLogServiceMethods.ByName("GetHttpRequestLog")), + connect.WithClientOptions(opts...), + ), + listHttpRequestLogs: connect.NewClient[ListHttpRequestLogsRequest, ListHttpRequestLogsResponse]( + httpClient, + baseURL+HttpRequestLogServiceListHttpRequestLogsProcedure, + connect.WithSchema(httpRequestLogServiceMethods.ByName("ListHttpRequestLogs")), + connect.WithClientOptions(opts...), + ), + clearHttpRequestLogs: connect.NewClient[ClearHttpRequestLogsRequest, ClearHttpRequestLogsResponse]( + httpClient, + baseURL+HttpRequestLogServiceClearHttpRequestLogsProcedure, + connect.WithSchema(httpRequestLogServiceMethods.ByName("ClearHttpRequestLogs")), + connect.WithClientOptions(opts...), + ), + } +} + +// httpRequestLogServiceClient implements HttpRequestLogServiceClient. +type httpRequestLogServiceClient struct { + getHttpRequestLog *connect.Client[GetHttpRequestLogRequest, GetHttpRequestLogResponse] + listHttpRequestLogs *connect.Client[ListHttpRequestLogsRequest, ListHttpRequestLogsResponse] + clearHttpRequestLogs *connect.Client[ClearHttpRequestLogsRequest, ClearHttpRequestLogsResponse] +} + +// GetHttpRequestLog calls hetty.reqlog.v1.HttpRequestLogService.GetHttpRequestLog. +func (c *httpRequestLogServiceClient) GetHttpRequestLog(ctx context.Context, req *connect.Request[GetHttpRequestLogRequest]) (*connect.Response[GetHttpRequestLogResponse], error) { + return c.getHttpRequestLog.CallUnary(ctx, req) +} + +// ListHttpRequestLogs calls hetty.reqlog.v1.HttpRequestLogService.ListHttpRequestLogs. +func (c *httpRequestLogServiceClient) ListHttpRequestLogs(ctx context.Context, req *connect.Request[ListHttpRequestLogsRequest]) (*connect.Response[ListHttpRequestLogsResponse], error) { + return c.listHttpRequestLogs.CallUnary(ctx, req) +} + +// ClearHttpRequestLogs calls hetty.reqlog.v1.HttpRequestLogService.ClearHttpRequestLogs. +func (c *httpRequestLogServiceClient) ClearHttpRequestLogs(ctx context.Context, req *connect.Request[ClearHttpRequestLogsRequest]) (*connect.Response[ClearHttpRequestLogsResponse], error) { + return c.clearHttpRequestLogs.CallUnary(ctx, req) +} + +// HttpRequestLogServiceHandler is an implementation of the hetty.reqlog.v1.HttpRequestLogService +// service. +type HttpRequestLogServiceHandler interface { + GetHttpRequestLog(context.Context, *connect.Request[GetHttpRequestLogRequest]) (*connect.Response[GetHttpRequestLogResponse], error) + ListHttpRequestLogs(context.Context, *connect.Request[ListHttpRequestLogsRequest]) (*connect.Response[ListHttpRequestLogsResponse], error) + ClearHttpRequestLogs(context.Context, *connect.Request[ClearHttpRequestLogsRequest]) (*connect.Response[ClearHttpRequestLogsResponse], error) +} + +// NewHttpRequestLogServiceHandler builds an HTTP handler from the service implementation. It +// returns the path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewHttpRequestLogServiceHandler(svc HttpRequestLogServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + httpRequestLogServiceMethods := File_reqlog_reqlog_proto.Services().ByName("HttpRequestLogService").Methods() + httpRequestLogServiceGetHttpRequestLogHandler := connect.NewUnaryHandler( + HttpRequestLogServiceGetHttpRequestLogProcedure, + svc.GetHttpRequestLog, + connect.WithSchema(httpRequestLogServiceMethods.ByName("GetHttpRequestLog")), + connect.WithHandlerOptions(opts...), + ) + httpRequestLogServiceListHttpRequestLogsHandler := connect.NewUnaryHandler( + HttpRequestLogServiceListHttpRequestLogsProcedure, + svc.ListHttpRequestLogs, + connect.WithSchema(httpRequestLogServiceMethods.ByName("ListHttpRequestLogs")), + connect.WithHandlerOptions(opts...), + ) + httpRequestLogServiceClearHttpRequestLogsHandler := connect.NewUnaryHandler( + HttpRequestLogServiceClearHttpRequestLogsProcedure, + svc.ClearHttpRequestLogs, + connect.WithSchema(httpRequestLogServiceMethods.ByName("ClearHttpRequestLogs")), + connect.WithHandlerOptions(opts...), + ) + return "/hetty.reqlog.v1.HttpRequestLogService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case HttpRequestLogServiceGetHttpRequestLogProcedure: + httpRequestLogServiceGetHttpRequestLogHandler.ServeHTTP(w, r) + case HttpRequestLogServiceListHttpRequestLogsProcedure: + httpRequestLogServiceListHttpRequestLogsHandler.ServeHTTP(w, r) + case HttpRequestLogServiceClearHttpRequestLogsProcedure: + httpRequestLogServiceClearHttpRequestLogsHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedHttpRequestLogServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedHttpRequestLogServiceHandler struct{} + +func (UnimplementedHttpRequestLogServiceHandler) GetHttpRequestLog(context.Context, *connect.Request[GetHttpRequestLogRequest]) (*connect.Response[GetHttpRequestLogResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hetty.reqlog.v1.HttpRequestLogService.GetHttpRequestLog is not implemented")) +} + +func (UnimplementedHttpRequestLogServiceHandler) ListHttpRequestLogs(context.Context, *connect.Request[ListHttpRequestLogsRequest]) (*connect.Response[ListHttpRequestLogsResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hetty.reqlog.v1.HttpRequestLogService.ListHttpRequestLogs is not implemented")) +} + +func (UnimplementedHttpRequestLogServiceHandler) ClearHttpRequestLogs(context.Context, *connect.Request[ClearHttpRequestLogsRequest]) (*connect.Response[ClearHttpRequestLogsResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hetty.reqlog.v1.HttpRequestLogService.ClearHttpRequestLogs is not implemented")) +} diff --git a/pkg/reqlog/reqlog.go b/pkg/reqlog/reqlog.go index c6ba8f7..6264c98 100644 --- a/pkg/reqlog/reqlog.go +++ b/pkg/reqlog/reqlog.go @@ -6,13 +6,13 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" - "net/url" - "github.com/oklog/ulid" + "connectrpc.com/connect" + "github.com/oklog/ulid/v2" "github.com/dstotijn/hetty/pkg/filter" + httppb "github.com/dstotijn/hetty/pkg/http" "github.com/dstotijn/hetty/pkg/log" "github.com/dstotijn/hetty/pkg/proxy" "github.com/dstotijn/hetty/pkg/scope" @@ -26,48 +26,21 @@ const ( ) var ( - ErrRequestNotFound = errors.New("reqlog: request not found") + ErrRequestLogNotFound = errors.New("reqlog: request not found") ErrProjectIDMustBeSet = errors.New("reqlog: project ID must be set") ) -type RequestLog struct { - ID ulid.ULID - ProjectID ulid.ULID - - URL *url.URL - Method string - Proto string - Header http.Header - Body []byte - - Response *ResponseLog -} - -type ResponseLog struct { - Proto string - StatusCode int - Status string - Header http.Header - Body []byte -} - type Service struct { bypassOutOfScopeRequests bool - findReqsFilter FindRequestsFilter - activeProjectID ulid.ULID + reqsFilter *RequestLogsFilter + activeProjectID string scope *scope.Scope repo Repository logger log.Logger } -type FindRequestsFilter struct { - ProjectID ulid.ULID - OnlyInScope bool - SearchExpr filter.Expression -} - type Config struct { - ActiveProjectID ulid.ULID + ActiveProjectID string Scope *scope.Scope Repository Repository Logger log.Logger @@ -88,25 +61,92 @@ func NewService(cfg Config) *Service { return s } -func (svc *Service) FindRequests(ctx context.Context) ([]RequestLog, error) { - return svc.repo.FindRequestLogs(ctx, svc.findReqsFilter, svc.scope) +func (svc *Service) ListHttpRequestLogs(ctx context.Context, req *connect.Request[ListHttpRequestLogsRequest]) (*connect.Response[ListHttpRequestLogsResponse], error) { + projectID := svc.activeProjectID + if projectID == "" { + return nil, connect.NewError(connect.CodeFailedPrecondition, ErrProjectIDMustBeSet) + } + + reqLogs, err := svc.repo.FindRequestLogs(ctx, projectID, svc.filterRequestLog) + if err != nil { + return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("reqlog: failed to find request logs: %w", err)) + } + + return connect.NewResponse(&ListHttpRequestLogsResponse{ + HttpRequestLogs: reqLogs, + }), nil } -func (svc *Service) FindRequestLogByID(ctx context.Context, id ulid.ULID) (RequestLog, error) { +func (svc *Service) filterRequestLog(reqLog *HttpRequestLog) (bool, error) { + if svc.reqsFilter.GetOnlyInScope() && svc.scope != nil && !reqLog.MatchScope(svc.scope) { + return false, nil + } + + var f filter.Expression + var err error + if expr := svc.reqsFilter.GetSearchExpr(); expr != "" { + f, err = filter.ParseQuery(expr) + if err != nil { + return false, fmt.Errorf("failed to parse search expression: %w", err) + } + } + + if f == nil { + return true, nil + } + + match, err := reqLog.Matches(f) + if err != nil { + return false, fmt.Errorf("failed to match search expression for request log (id: %v): %w", reqLog.Id, err) + } + + return match, nil +} + +func (svc *Service) FindRequestLogByID(ctx context.Context, id string) (*HttpRequestLog, error) { + if svc.activeProjectID == "" { + return nil, connect.NewError(connect.CodeFailedPrecondition, ErrProjectIDMustBeSet) + } + return svc.repo.FindRequestLogByID(ctx, svc.activeProjectID, id) } -func (svc *Service) ClearRequests(ctx context.Context, projectID ulid.ULID) error { - return svc.repo.ClearRequestLogs(ctx, projectID) +// GetHttpRequestLog implements HttpRequestLogServiceHandler. +func (svc *Service) GetHttpRequestLog(ctx context.Context, req *connect.Request[GetHttpRequestLogRequest]) (*connect.Response[GetHttpRequestLogResponse], error) { + id, err := ulid.Parse(req.Msg.Id) + if err != nil { + return nil, connect.NewError(connect.CodeInvalidArgument, err) + } + + reqLog, err := svc.repo.FindRequestLogByID(ctx, svc.activeProjectID, id.String()) + if errors.Is(err, ErrRequestLogNotFound) { + return nil, connect.NewError(connect.CodeNotFound, err) + } + if err != nil { + return nil, connect.NewError(connect.CodeInternal, err) + } + + return connect.NewResponse(&GetHttpRequestLogResponse{ + HttpRequestLog: reqLog, + }), nil } -func (svc *Service) storeResponse(ctx context.Context, reqLogID ulid.ULID, res *http.Response) error { - resLog, err := ParseHTTPResponse(res) +func (svc *Service) ClearHttpRequestLogs(ctx context.Context, req *connect.Request[ClearHttpRequestLogsRequest]) (*connect.Response[ClearHttpRequestLogsResponse], error) { + err := svc.repo.ClearRequestLogs(ctx, svc.activeProjectID) + if err != nil { + return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("reqlog: failed to clear request logs: %w", err)) + } + + return connect.NewResponse(&ClearHttpRequestLogsResponse{}), nil +} + +func (svc *Service) storeResponse(ctx context.Context, reqLogID string, res *http.Response) error { + respb, err := httppb.ParseHTTPResponse(res) if err != nil { return err } - return svc.repo.StoreResponseLog(ctx, svc.activeProjectID, reqLogID, resLog) + return svc.repo.StoreResponseLog(ctx, svc.activeProjectID, reqLogID, respb) } func (svc *Service) RequestModifier(next proxy.RequestModifyFunc) proxy.RequestModifyFunc { @@ -121,19 +161,19 @@ func (svc *Service) RequestModifier(next proxy.RequestModifyFunc) proxy.RequestM // TODO: Use io.LimitReader. var err error - body, err = ioutil.ReadAll(req.Body) + body, err = io.ReadAll(req.Body) if err != nil { svc.logger.Errorw("Failed to read request body for logging.", "error", err) return } - req.Body = ioutil.NopCloser(bytes.NewBuffer(body)) - clone.Body = ioutil.NopCloser(bytes.NewBuffer(body)) + req.Body = io.NopCloser(bytes.NewBuffer(body)) + clone.Body = io.NopCloser(bytes.NewBuffer(body)) } // Bypass logging if no project is active. - if svc.activeProjectID.Compare(ulid.ULID{}) == 0 { + if svc.activeProjectID == "" { ctx := context.WithValue(req.Context(), LogBypassedKey, true) *req = *req.WithContext(ctx) @@ -161,14 +201,37 @@ func (svc *Service) RequestModifier(next proxy.RequestModifyFunc) proxy.RequestM return } - reqLog := RequestLog{ - ID: reqID, - ProjectID: svc.activeProjectID, - Method: clone.Method, - URL: clone.URL, - Proto: clone.Proto, - Header: clone.Header, - Body: body, + proto, ok := httppb.ProtoMap[clone.Proto] + if !ok { + svc.logger.Errorw("Bypassed logging: request has an invalid protocol.", + "proto", clone.Proto) + return + } + + method, ok := httppb.MethodMap[clone.Method] + if !ok { + svc.logger.Errorw("Bypassed logging: request has an invalid method.", + "method", clone.Method) + return + } + + headers := []*httppb.Header{} + for k, v := range clone.Header { + for _, vv := range v { + headers = append(headers, &httppb.Header{Key: k, Value: vv}) + } + } + + reqLog := &HttpRequestLog{ + Id: reqID.String(), + ProjectId: svc.activeProjectID, + Request: &httppb.Request{ + Url: clone.URL.String(), + Method: method, + Protocol: proto, + Headers: headers, + Body: body, + }, } err := svc.repo.StoreRequestLog(req.Context(), reqLog) @@ -179,10 +242,10 @@ func (svc *Service) RequestModifier(next proxy.RequestModifyFunc) proxy.RequestM } svc.logger.Debugw("Stored request log.", - "reqLogID", reqLog.ID.String(), - "url", reqLog.URL.String()) - - ctx := context.WithValue(req.Context(), ReqLogIDKey, reqLog.ID) + "reqLogID", reqLog.Id, + "url", reqLog.Request.Url, + ) + ctx := context.WithValue(req.Context(), ReqLogIDKey, reqID) *req = *req.WithContext(ctx) } } @@ -216,7 +279,7 @@ func (svc *Service) ResponseModifier(next proxy.ResponseModifyFunc) proxy.Respon } go func() { - if err := svc.storeResponse(context.Background(), reqLogID, &clone); err != nil { + if err := svc.storeResponse(context.Background(), reqLogID.String(), &clone); err != nil { svc.logger.Errorw("Failed to store response log.", "error", err) } else { @@ -229,20 +292,16 @@ func (svc *Service) ResponseModifier(next proxy.ResponseModifyFunc) proxy.Respon } } -func (svc *Service) SetActiveProjectID(id ulid.ULID) { +func (svc *Service) SetActiveProjectID(id string) { svc.activeProjectID = id } -func (svc *Service) ActiveProjectID() ulid.ULID { +func (svc *Service) ActiveProjectID() string { return svc.activeProjectID } -func (svc *Service) SetFindReqsFilter(filter FindRequestsFilter) { - svc.findReqsFilter = filter -} - -func (svc *Service) FindReqsFilter() FindRequestsFilter { - return svc.findReqsFilter +func (svc *Service) SetRequestLogsFilter(filter *RequestLogsFilter) { + svc.reqsFilter = filter } func (svc *Service) SetBypassOutOfScopeRequests(bypass bool) { @@ -252,18 +311,3 @@ func (svc *Service) SetBypassOutOfScopeRequests(bypass bool) { func (svc *Service) BypassOutOfScopeRequests() bool { return svc.bypassOutOfScopeRequests } - -func ParseHTTPResponse(res *http.Response) (ResponseLog, error) { - body, err := io.ReadAll(res.Body) - if err != nil { - return ResponseLog{}, fmt.Errorf("reqlog: could not read body: %w", err) - } - - return ResponseLog{ - Proto: res.Proto, - StatusCode: res.StatusCode, - Status: res.Status, - Header: res.Header, - Body: body, - }, nil -} diff --git a/pkg/reqlog/reqlog.pb.go b/pkg/reqlog/reqlog.pb.go new file mode 100644 index 0000000..d58633b --- /dev/null +++ b/pkg/reqlog/reqlog.pb.go @@ -0,0 +1,533 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.3 +// protoc (unknown) +// source: reqlog/reqlog.proto + +package reqlog + +import ( + http "github.com/dstotijn/hetty/pkg/http" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type HttpRequestLog struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + ProjectId string `protobuf:"bytes,2,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` + RemoteIp string `protobuf:"bytes,3,opt,name=remote_ip,json=remoteIp,proto3" json:"remote_ip,omitempty"` + Request *http.Request `protobuf:"bytes,4,opt,name=request,proto3" json:"request,omitempty"` + Response *http.Response `protobuf:"bytes,5,opt,name=response,proto3" json:"response,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *HttpRequestLog) Reset() { + *x = HttpRequestLog{} + mi := &file_reqlog_reqlog_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *HttpRequestLog) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HttpRequestLog) ProtoMessage() {} + +func (x *HttpRequestLog) ProtoReflect() protoreflect.Message { + mi := &file_reqlog_reqlog_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HttpRequestLog.ProtoReflect.Descriptor instead. +func (*HttpRequestLog) Descriptor() ([]byte, []int) { + return file_reqlog_reqlog_proto_rawDescGZIP(), []int{0} +} + +func (x *HttpRequestLog) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *HttpRequestLog) GetProjectId() string { + if x != nil { + return x.ProjectId + } + return "" +} + +func (x *HttpRequestLog) GetRemoteIp() string { + if x != nil { + return x.RemoteIp + } + return "" +} + +func (x *HttpRequestLog) GetRequest() *http.Request { + if x != nil { + return x.Request + } + return nil +} + +func (x *HttpRequestLog) GetResponse() *http.Response { + if x != nil { + return x.Response + } + return nil +} + +type GetHttpRequestLogRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetHttpRequestLogRequest) Reset() { + *x = GetHttpRequestLogRequest{} + mi := &file_reqlog_reqlog_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetHttpRequestLogRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetHttpRequestLogRequest) ProtoMessage() {} + +func (x *GetHttpRequestLogRequest) ProtoReflect() protoreflect.Message { + mi := &file_reqlog_reqlog_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetHttpRequestLogRequest.ProtoReflect.Descriptor instead. +func (*GetHttpRequestLogRequest) Descriptor() ([]byte, []int) { + return file_reqlog_reqlog_proto_rawDescGZIP(), []int{1} +} + +func (x *GetHttpRequestLogRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +type GetHttpRequestLogResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + HttpRequestLog *HttpRequestLog `protobuf:"bytes,1,opt,name=http_request_log,json=httpRequestLog,proto3" json:"http_request_log,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetHttpRequestLogResponse) Reset() { + *x = GetHttpRequestLogResponse{} + mi := &file_reqlog_reqlog_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetHttpRequestLogResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetHttpRequestLogResponse) ProtoMessage() {} + +func (x *GetHttpRequestLogResponse) ProtoReflect() protoreflect.Message { + mi := &file_reqlog_reqlog_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetHttpRequestLogResponse.ProtoReflect.Descriptor instead. +func (*GetHttpRequestLogResponse) Descriptor() ([]byte, []int) { + return file_reqlog_reqlog_proto_rawDescGZIP(), []int{2} +} + +func (x *GetHttpRequestLogResponse) GetHttpRequestLog() *HttpRequestLog { + if x != nil { + return x.HttpRequestLog + } + return nil +} + +type ListHttpRequestLogsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListHttpRequestLogsRequest) Reset() { + *x = ListHttpRequestLogsRequest{} + mi := &file_reqlog_reqlog_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListHttpRequestLogsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListHttpRequestLogsRequest) ProtoMessage() {} + +func (x *ListHttpRequestLogsRequest) ProtoReflect() protoreflect.Message { + mi := &file_reqlog_reqlog_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListHttpRequestLogsRequest.ProtoReflect.Descriptor instead. +func (*ListHttpRequestLogsRequest) Descriptor() ([]byte, []int) { + return file_reqlog_reqlog_proto_rawDescGZIP(), []int{3} +} + +type ListHttpRequestLogsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + HttpRequestLogs []*HttpRequestLog `protobuf:"bytes,1,rep,name=http_request_logs,json=httpRequestLogs,proto3" json:"http_request_logs,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListHttpRequestLogsResponse) Reset() { + *x = ListHttpRequestLogsResponse{} + mi := &file_reqlog_reqlog_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListHttpRequestLogsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListHttpRequestLogsResponse) ProtoMessage() {} + +func (x *ListHttpRequestLogsResponse) ProtoReflect() protoreflect.Message { + mi := &file_reqlog_reqlog_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListHttpRequestLogsResponse.ProtoReflect.Descriptor instead. +func (*ListHttpRequestLogsResponse) Descriptor() ([]byte, []int) { + return file_reqlog_reqlog_proto_rawDescGZIP(), []int{4} +} + +func (x *ListHttpRequestLogsResponse) GetHttpRequestLogs() []*HttpRequestLog { + if x != nil { + return x.HttpRequestLogs + } + return nil +} + +type RequestLogsFilter struct { + state protoimpl.MessageState `protogen:"open.v1"` + OnlyInScope bool `protobuf:"varint,1,opt,name=only_in_scope,json=onlyInScope,proto3" json:"only_in_scope,omitempty"` + SearchExpr string `protobuf:"bytes,2,opt,name=search_expr,json=searchExpr,proto3" json:"search_expr,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RequestLogsFilter) Reset() { + *x = RequestLogsFilter{} + mi := &file_reqlog_reqlog_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RequestLogsFilter) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequestLogsFilter) ProtoMessage() {} + +func (x *RequestLogsFilter) ProtoReflect() protoreflect.Message { + mi := &file_reqlog_reqlog_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RequestLogsFilter.ProtoReflect.Descriptor instead. +func (*RequestLogsFilter) Descriptor() ([]byte, []int) { + return file_reqlog_reqlog_proto_rawDescGZIP(), []int{5} +} + +func (x *RequestLogsFilter) GetOnlyInScope() bool { + if x != nil { + return x.OnlyInScope + } + return false +} + +func (x *RequestLogsFilter) GetSearchExpr() string { + if x != nil { + return x.SearchExpr + } + return "" +} + +type ClearHttpRequestLogsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ClearHttpRequestLogsRequest) Reset() { + *x = ClearHttpRequestLogsRequest{} + mi := &file_reqlog_reqlog_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ClearHttpRequestLogsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ClearHttpRequestLogsRequest) ProtoMessage() {} + +func (x *ClearHttpRequestLogsRequest) ProtoReflect() protoreflect.Message { + mi := &file_reqlog_reqlog_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ClearHttpRequestLogsRequest.ProtoReflect.Descriptor instead. +func (*ClearHttpRequestLogsRequest) Descriptor() ([]byte, []int) { + return file_reqlog_reqlog_proto_rawDescGZIP(), []int{6} +} + +type ClearHttpRequestLogsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ClearHttpRequestLogsResponse) Reset() { + *x = ClearHttpRequestLogsResponse{} + mi := &file_reqlog_reqlog_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ClearHttpRequestLogsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ClearHttpRequestLogsResponse) ProtoMessage() {} + +func (x *ClearHttpRequestLogsResponse) ProtoReflect() protoreflect.Message { + mi := &file_reqlog_reqlog_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ClearHttpRequestLogsResponse.ProtoReflect.Descriptor instead. +func (*ClearHttpRequestLogsResponse) Descriptor() ([]byte, []int) { + return file_reqlog_reqlog_proto_rawDescGZIP(), []int{7} +} + +var File_reqlog_reqlog_proto protoreflect.FileDescriptor + +var file_reqlog_reqlog_proto_rawDesc = []byte{ + 0x0a, 0x13, 0x72, 0x65, 0x71, 0x6c, 0x6f, 0x67, 0x2f, 0x72, 0x65, 0x71, 0x6c, 0x6f, 0x67, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x72, 0x65, 0x71, + 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x1a, 0x0f, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x68, 0x74, 0x74, + 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc3, 0x01, 0x0a, 0x0e, 0x48, 0x74, 0x74, 0x70, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x65, 0x6d, + 0x6f, 0x74, 0x65, 0x5f, 0x69, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, + 0x6d, 0x6f, 0x74, 0x65, 0x49, 0x70, 0x12, 0x30, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, + 0x68, 0x74, 0x74, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, + 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x33, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x68, 0x65, 0x74, + 0x74, 0x79, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2a, 0x0a, + 0x18, 0x47, 0x65, 0x74, 0x48, 0x74, 0x74, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, + 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x66, 0x0a, 0x19, 0x47, 0x65, 0x74, + 0x48, 0x74, 0x74, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, 0x10, 0x68, 0x74, 0x74, 0x70, 0x5f, 0x72, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x6c, 0x6f, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1f, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x72, 0x65, 0x71, 0x6c, 0x6f, 0x67, 0x2e, + 0x76, 0x31, 0x2e, 0x48, 0x74, 0x74, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, + 0x67, 0x52, 0x0e, 0x68, 0x74, 0x74, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, + 0x67, 0x22, 0x1c, 0x0a, 0x1a, 0x4c, 0x69, 0x73, 0x74, 0x48, 0x74, 0x74, 0x70, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, + 0x6a, 0x0a, 0x1b, 0x4c, 0x69, 0x73, 0x74, 0x48, 0x74, 0x74, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4b, + 0x0a, 0x11, 0x68, 0x74, 0x74, 0x70, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x6c, + 0x6f, 0x67, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x68, 0x65, 0x74, 0x74, + 0x79, 0x2e, 0x72, 0x65, 0x71, 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x74, 0x74, 0x70, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x52, 0x0f, 0x68, 0x74, 0x74, 0x70, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x58, 0x0a, 0x11, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, + 0x12, 0x22, 0x0a, 0x0d, 0x6f, 0x6e, 0x6c, 0x79, 0x5f, 0x69, 0x6e, 0x5f, 0x73, 0x63, 0x6f, 0x70, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x6f, 0x6e, 0x6c, 0x79, 0x49, 0x6e, 0x53, + 0x63, 0x6f, 0x70, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x5f, 0x65, + 0x78, 0x70, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x61, 0x72, 0x63, + 0x68, 0x45, 0x78, 0x70, 0x72, 0x22, 0x1d, 0x0a, 0x1b, 0x43, 0x6c, 0x65, 0x61, 0x72, 0x48, 0x74, + 0x74, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x22, 0x1e, 0x0a, 0x1c, 0x43, 0x6c, 0x65, 0x61, 0x72, 0x48, 0x74, 0x74, + 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xf0, 0x02, 0x0a, 0x15, 0x48, 0x74, 0x74, 0x70, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6c, + 0x0a, 0x11, 0x47, 0x65, 0x74, 0x48, 0x74, 0x74, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x4c, 0x6f, 0x67, 0x12, 0x29, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x72, 0x65, 0x71, 0x6c, + 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x48, 0x74, 0x74, 0x70, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, + 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x72, 0x65, 0x71, 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, + 0x2e, 0x47, 0x65, 0x74, 0x48, 0x74, 0x74, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, + 0x6f, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x72, 0x0a, 0x13, + 0x4c, 0x69, 0x73, 0x74, 0x48, 0x74, 0x74, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, + 0x6f, 0x67, 0x73, 0x12, 0x2b, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x72, 0x65, 0x71, 0x6c, + 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x48, 0x74, 0x74, 0x70, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x2c, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x72, 0x65, 0x71, 0x6c, 0x6f, 0x67, 0x2e, + 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x48, 0x74, 0x74, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x75, 0x0a, 0x14, 0x43, 0x6c, 0x65, 0x61, 0x72, 0x48, 0x74, 0x74, 0x70, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x2c, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, + 0x2e, 0x72, 0x65, 0x71, 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6c, 0x65, 0x61, 0x72, + 0x48, 0x74, 0x74, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x72, + 0x65, 0x71, 0x6c, 0x6f, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6c, 0x65, 0x61, 0x72, 0x48, 0x74, + 0x74, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x73, 0x74, 0x6f, 0x74, 0x69, 0x6a, 0x6e, 0x2f, 0x68, + 0x65, 0x74, 0x74, 0x79, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x65, 0x71, 0x6c, 0x6f, 0x67, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_reqlog_reqlog_proto_rawDescOnce sync.Once + file_reqlog_reqlog_proto_rawDescData = file_reqlog_reqlog_proto_rawDesc +) + +func file_reqlog_reqlog_proto_rawDescGZIP() []byte { + file_reqlog_reqlog_proto_rawDescOnce.Do(func() { + file_reqlog_reqlog_proto_rawDescData = protoimpl.X.CompressGZIP(file_reqlog_reqlog_proto_rawDescData) + }) + return file_reqlog_reqlog_proto_rawDescData +} + +var file_reqlog_reqlog_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_reqlog_reqlog_proto_goTypes = []any{ + (*HttpRequestLog)(nil), // 0: hetty.reqlog.v1.HttpRequestLog + (*GetHttpRequestLogRequest)(nil), // 1: hetty.reqlog.v1.GetHttpRequestLogRequest + (*GetHttpRequestLogResponse)(nil), // 2: hetty.reqlog.v1.GetHttpRequestLogResponse + (*ListHttpRequestLogsRequest)(nil), // 3: hetty.reqlog.v1.ListHttpRequestLogsRequest + (*ListHttpRequestLogsResponse)(nil), // 4: hetty.reqlog.v1.ListHttpRequestLogsResponse + (*RequestLogsFilter)(nil), // 5: hetty.reqlog.v1.RequestLogsFilter + (*ClearHttpRequestLogsRequest)(nil), // 6: hetty.reqlog.v1.ClearHttpRequestLogsRequest + (*ClearHttpRequestLogsResponse)(nil), // 7: hetty.reqlog.v1.ClearHttpRequestLogsResponse + (*http.Request)(nil), // 8: hetty.http.v1.Request + (*http.Response)(nil), // 9: hetty.http.v1.Response +} +var file_reqlog_reqlog_proto_depIdxs = []int32{ + 8, // 0: hetty.reqlog.v1.HttpRequestLog.request:type_name -> hetty.http.v1.Request + 9, // 1: hetty.reqlog.v1.HttpRequestLog.response:type_name -> hetty.http.v1.Response + 0, // 2: hetty.reqlog.v1.GetHttpRequestLogResponse.http_request_log:type_name -> hetty.reqlog.v1.HttpRequestLog + 0, // 3: hetty.reqlog.v1.ListHttpRequestLogsResponse.http_request_logs:type_name -> hetty.reqlog.v1.HttpRequestLog + 1, // 4: hetty.reqlog.v1.HttpRequestLogService.GetHttpRequestLog:input_type -> hetty.reqlog.v1.GetHttpRequestLogRequest + 3, // 5: hetty.reqlog.v1.HttpRequestLogService.ListHttpRequestLogs:input_type -> hetty.reqlog.v1.ListHttpRequestLogsRequest + 6, // 6: hetty.reqlog.v1.HttpRequestLogService.ClearHttpRequestLogs:input_type -> hetty.reqlog.v1.ClearHttpRequestLogsRequest + 2, // 7: hetty.reqlog.v1.HttpRequestLogService.GetHttpRequestLog:output_type -> hetty.reqlog.v1.GetHttpRequestLogResponse + 4, // 8: hetty.reqlog.v1.HttpRequestLogService.ListHttpRequestLogs:output_type -> hetty.reqlog.v1.ListHttpRequestLogsResponse + 7, // 9: hetty.reqlog.v1.HttpRequestLogService.ClearHttpRequestLogs:output_type -> hetty.reqlog.v1.ClearHttpRequestLogsResponse + 7, // [7:10] is the sub-list for method output_type + 4, // [4:7] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_reqlog_reqlog_proto_init() } +func file_reqlog_reqlog_proto_init() { + if File_reqlog_reqlog_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_reqlog_reqlog_proto_rawDesc, + NumEnums: 0, + NumMessages: 8, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_reqlog_reqlog_proto_goTypes, + DependencyIndexes: file_reqlog_reqlog_proto_depIdxs, + MessageInfos: file_reqlog_reqlog_proto_msgTypes, + }.Build() + File_reqlog_reqlog_proto = out.File + file_reqlog_reqlog_proto_rawDesc = nil + file_reqlog_reqlog_proto_goTypes = nil + file_reqlog_reqlog_proto_depIdxs = nil +} diff --git a/pkg/reqlog/reqlog_test.go b/pkg/reqlog/reqlog_test.go index acee01b..6626490 100644 --- a/pkg/reqlog/reqlog_test.go +++ b/pkg/reqlog/reqlog_test.go @@ -3,27 +3,24 @@ package reqlog_test import ( "context" "io" - "math/rand" "net/http" "net/http/httptest" "strings" "testing" "time" - "github.com/google/go-cmp/cmp" - "github.com/oklog/ulid" + "github.com/oklog/ulid/v2" "go.etcd.io/bbolt" "github.com/dstotijn/hetty/pkg/db/bolt" + httppb "github.com/dstotijn/hetty/pkg/http" "github.com/dstotijn/hetty/pkg/proj" "github.com/dstotijn/hetty/pkg/proxy" "github.com/dstotijn/hetty/pkg/reqlog" "github.com/dstotijn/hetty/pkg/scope" + "github.com/dstotijn/hetty/pkg/testutil" ) -//nolint:gosec -var ulidEntropy = rand.New(rand.NewSource(time.Now().UnixNano())) - //nolint:paralleltest func TestRequestModifier(t *testing.T) { path := t.TempDir() + "bolt.db" @@ -39,9 +36,9 @@ func TestRequestModifier(t *testing.T) { } defer db.Close() - projectID := ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) - err = db.UpsertProject(context.Background(), proj.Project{ - ID: projectID, + projectID := ulid.Make().String() + err = db.UpsertProject(context.Background(), &proj.Project{ + Id: projectID, }) if err != nil { t.Fatalf("unexpected error upserting project: %v", err) @@ -58,34 +55,39 @@ func TestRequestModifier(t *testing.T) { } reqModFn := svc.RequestModifier(next) req := httptest.NewRequest("GET", "https://example.com/", strings.NewReader("bar")) - reqID := ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) + req.Header.Add("X-Yolo", "swag") + reqID := ulid.Make() req = req.WithContext(proxy.WithRequestID(req.Context(), reqID)) reqModFn(req) t.Run("request log was stored in repository", func(t *testing.T) { - exp := reqlog.RequestLog{ - ID: reqID, - ProjectID: svc.ActiveProjectID(), - Method: req.Method, - URL: req.URL, - Proto: req.Proto, - Header: req.Header, - Body: []byte("modified body"), + exp := &reqlog.HttpRequestLog{ + Id: reqID.String(), + ProjectId: svc.ActiveProjectID(), + Request: &httppb.Request{ + Url: "https://example.com/", + Method: httppb.Method_METHOD_GET, + Protocol: httppb.Protocol_PROTOCOL_HTTP11, + Headers: []*httppb.Header{ + { + Key: "X-Yolo", + Value: "swag", + }, + }, + Body: []byte("modified body"), + }, } - got, err := svc.FindRequestLogByID(context.Background(), reqID) + got, err := db.FindRequestLogByID(context.Background(), svc.ActiveProjectID(), reqID.String()) if err != nil { t.Fatalf("failed to find request by id: %v", err) } - if diff := cmp.Diff(exp, got); diff != "" { - t.Fatalf("request log not equal (-exp, +got):\n%v", diff) - } + testutil.ProtoDiff(t, "request log not equal", exp, got) }) } -//nolint:paralleltest func TestResponseModifier(t *testing.T) { path := t.TempDir() + "bolt.db" boltDB, err := bbolt.Open(path, 0o600, nil) @@ -100,9 +102,9 @@ func TestResponseModifier(t *testing.T) { } defer db.Close() - projectID := ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) - err = db.UpsertProject(context.Background(), proj.Project{ - ID: projectID, + projectID := "foobar-project-id" + err = db.UpsertProject(context.Background(), &proj.Project{ + Id: projectID, }) if err != nil { t.Fatalf("unexpected error upserting project: %v", err) @@ -120,39 +122,44 @@ func TestResponseModifier(t *testing.T) { resModFn := svc.ResponseModifier(next) req := httptest.NewRequest("GET", "https://example.com/", strings.NewReader("bar")) - reqLogID := ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) + reqLogID := ulid.Make() req = req.WithContext(context.WithValue(req.Context(), reqlog.ReqLogIDKey, reqLogID)) - err = db.StoreRequestLog(context.Background(), reqlog.RequestLog{ - ID: reqLogID, - ProjectID: projectID, + err = db.StoreRequestLog(context.Background(), &reqlog.HttpRequestLog{ + Id: reqLogID.String(), + ProjectId: projectID, }) if err != nil { t.Fatalf("failed to store request log: %v", err) } res := &http.Response{ - Request: req, - Body: io.NopCloser(strings.NewReader("bar")), + Request: req, + Proto: "HTTP/1.1", + Status: "200 OK", + StatusCode: 200, + Body: io.NopCloser(strings.NewReader("bar")), } if err := resModFn(res); err != nil { t.Fatalf("unexpected error (expected: nil, got: %v)", err) } - t.Run("request log was stored in repository", func(t *testing.T) { - // Dirty (but simple) wait for other goroutine to finish calling repository. - time.Sleep(10 * time.Millisecond) + // Dirty (but simple) wait for other goroutine to finish calling repository. + time.Sleep(10 * time.Millisecond) - got, err := svc.FindRequestLogByID(context.Background(), reqLogID) - if err != nil { - t.Fatalf("failed to find request by id: %v", err) - } + got, err := db.FindRequestLogByID(context.Background(), svc.ActiveProjectID(), reqLogID.String()) + if err != nil { + t.Fatalf("failed to find request by id: %v", err) + } - t.Run("ran next modifier first, before calling repository", func(t *testing.T) { - if exp := "modified body"; exp != string(got.Response.Body) { - t.Fatalf("incorrect `ResponseLog.Body` value (expected: %v, got: %v)", exp, string(got.Response.Body)) - } - }) - }) + exp := &httppb.Response{ + Protocol: httppb.Protocol_PROTOCOL_HTTP11, + Status: "200 OK", + StatusCode: 200, + Headers: []*httppb.Header{}, + Body: []byte("modified body"), + } + + testutil.ProtoDiff(t, "response not equal", exp, got.GetResponse()) } diff --git a/pkg/reqlog/search.go b/pkg/reqlog/search.go index 0c7d73a..8777450 100644 --- a/pkg/reqlog/search.go +++ b/pkg/reqlog/search.go @@ -3,40 +3,34 @@ package reqlog import ( "errors" "fmt" - "strconv" "strings" - "github.com/oklog/ulid" + "github.com/oklog/ulid/v2" "github.com/dstotijn/hetty/pkg/filter" + "github.com/dstotijn/hetty/pkg/http" "github.com/dstotijn/hetty/pkg/scope" ) -var reqLogSearchKeyFns = map[string]func(rl RequestLog) string{ - "req.id": func(rl RequestLog) string { return rl.ID.String() }, - "req.proto": func(rl RequestLog) string { return rl.Proto }, - "req.url": func(rl RequestLog) string { - if rl.URL == nil { +var reqLogSearchKeyFns = map[string]func(rl *HttpRequestLog) string{ + "req.id": func(rl *HttpRequestLog) string { return rl.GetId() }, + "req.proto": func(rl *HttpRequestLog) string { return rl.GetRequest().GetProtocol().String() }, + "req.url": func(rl *HttpRequestLog) string { return rl.GetRequest().GetUrl() }, + "req.method": func(rl *HttpRequestLog) string { return rl.GetRequest().GetMethod().String() }, + "req.body": func(rl *HttpRequestLog) string { return string(rl.GetRequest().GetBody()) }, + "req.timestamp": func(rl *HttpRequestLog) string { + id, err := ulid.Parse(rl.GetId()) + if err != nil { return "" } - return rl.URL.String() + return ulid.Time(id.Time()).String() }, - "req.method": func(rl RequestLog) string { return rl.Method }, - "req.body": func(rl RequestLog) string { return string(rl.Body) }, - "req.timestamp": func(rl RequestLog) string { return ulid.Time(rl.ID.Time()).String() }, -} - -var ResLogSearchKeyFns = map[string]func(rl ResponseLog) string{ - "res.proto": func(rl ResponseLog) string { return rl.Proto }, - "res.statusCode": func(rl ResponseLog) string { return strconv.Itoa(rl.StatusCode) }, - "res.statusReason": func(rl ResponseLog) string { return rl.Status }, - "res.body": func(rl ResponseLog) string { return string(rl.Body) }, } // TODO: Request and response headers search key functions. // Matches returns true if the supplied search expression evaluates to true. -func (reqLog RequestLog) Matches(expr filter.Expression) (bool, error) { +func (reqLog *HttpRequestLog) Matches(expr filter.Expression) (bool, error) { switch e := expr.(type) { case filter.PrefixExpression: return reqLog.matchPrefixExpr(e) @@ -49,7 +43,7 @@ func (reqLog RequestLog) Matches(expr filter.Expression) (bool, error) { } } -func (reqLog RequestLog) matchPrefixExpr(expr filter.PrefixExpression) (bool, error) { +func (reqLog *HttpRequestLog) matchPrefixExpr(expr filter.PrefixExpression) (bool, error) { switch expr.Operator { case filter.TokOpNot: match, err := reqLog.Matches(expr.Right) @@ -63,7 +57,7 @@ func (reqLog RequestLog) matchPrefixExpr(expr filter.PrefixExpression) (bool, er } } -func (reqLog RequestLog) matchInfixExpr(expr filter.InfixExpression) (bool, error) { +func (reqLog *HttpRequestLog) matchInfixExpr(expr filter.InfixExpression) (bool, error) { switch expr.Operator { case filter.TokOpAnd: left, err := reqLog.Matches(expr.Left) @@ -99,7 +93,7 @@ func (reqLog RequestLog) matchInfixExpr(expr filter.InfixExpression) (bool, erro leftVal := reqLog.getMappedStringLiteral(left.Value) if leftVal == "req.headers" { - match, err := filter.MatchHTTPHeaders(expr.Operator, expr.Right, reqLog.Header) + match, err := filter.MatchHTTPHeaders(expr.Operator, expr.Right, reqLog.Request.Headers) if err != nil { return false, fmt.Errorf("failed to match request HTTP headers: %w", err) } @@ -108,7 +102,7 @@ func (reqLog RequestLog) matchInfixExpr(expr filter.InfixExpression) (bool, erro } if leftVal == "res.headers" && reqLog.Response != nil { - match, err := filter.MatchHTTPHeaders(expr.Operator, expr.Right, reqLog.Response.Header) + match, err := filter.MatchHTTPHeaders(expr.Operator, expr.Right, reqLog.Response.Headers) if err != nil { return false, fmt.Errorf("failed to match response HTTP headers: %w", err) } @@ -159,7 +153,7 @@ func (reqLog RequestLog) matchInfixExpr(expr filter.InfixExpression) (bool, erro } } -func (reqLog RequestLog) getMappedStringLiteral(s string) string { +func (reqLog *HttpRequestLog) getMappedStringLiteral(s string) string { switch { case strings.HasPrefix(s, "req."): fn, ok := reqLogSearchKeyFns[s] @@ -167,28 +161,22 @@ func (reqLog RequestLog) getMappedStringLiteral(s string) string { return fn(reqLog) } case strings.HasPrefix(s, "res."): - if reqLog.Response == nil { - return "" - } - - fn, ok := ResLogSearchKeyFns[s] + fn, ok := http.ResponseSearchKeyFns[s] if ok { - return fn(*reqLog.Response) + return fn(reqLog.GetResponse()) } } return s } -func (reqLog RequestLog) matchStringLiteral(strLiteral filter.StringLiteral) (bool, error) { - for key, values := range reqLog.Header { - for _, value := range values { - if strings.Contains( - strings.ToLower(fmt.Sprintf("%v: %v", key, value)), - strings.ToLower(strLiteral.Value), - ) { - return true, nil - } +func (reqLog *HttpRequestLog) matchStringLiteral(strLiteral filter.StringLiteral) (bool, error) { + for _, header := range reqLog.GetRequest().GetHeaders() { + if strings.Contains( + strings.ToLower(fmt.Sprintf("%v: %v", header.Key, header.Value)), + strings.ToLower(strLiteral.Value), + ) { + return true, nil } } @@ -201,21 +189,19 @@ func (reqLog RequestLog) matchStringLiteral(strLiteral filter.StringLiteral) (bo } } - if reqLog.Response != nil { - for key, values := range reqLog.Response.Header { - for _, value := range values { - if strings.Contains( - strings.ToLower(fmt.Sprintf("%v: %v", key, value)), - strings.ToLower(strLiteral.Value), - ) { - return true, nil - } + if res := reqLog.GetResponse(); res != nil { + for _, header := range res.Headers { + if strings.Contains( + strings.ToLower(fmt.Sprintf("%v: %v", header.Key, header.Value)), + strings.ToLower(strLiteral.Value), + ) { + return true, nil } } - for _, fn := range ResLogSearchKeyFns { + for _, fn := range http.ResponseSearchKeyFns { if strings.Contains( - strings.ToLower(fn(*reqLog.Response)), + strings.ToLower(fn(reqLog.GetResponse())), strings.ToLower(strLiteral.Value), ) { return true, nil @@ -226,29 +212,25 @@ func (reqLog RequestLog) matchStringLiteral(strLiteral filter.StringLiteral) (bo return false, nil } -func (reqLog RequestLog) MatchScope(s *scope.Scope) bool { +func (reqLog *HttpRequestLog) MatchScope(s *scope.Scope) bool { for _, rule := range s.Rules() { - if rule.URL != nil && reqLog.URL != nil { - if matches := rule.URL.MatchString(reqLog.URL.String()); matches { + if rule.URL != nil { + if matches := rule.URL.MatchString(reqLog.GetRequest().GetUrl()); matches { return true } } - for key, values := range reqLog.Header { + for _, header := range reqLog.GetRequest().GetHeaders() { var keyMatches, valueMatches bool - if rule.Header.Key != nil { - if matches := rule.Header.Key.MatchString(key); matches { - keyMatches = true - } + if matches := rule.Header.Key.MatchString(header.Key); matches { + keyMatches = true } if rule.Header.Value != nil { - for _, value := range values { - if matches := rule.Header.Value.MatchString(value); matches { - valueMatches = true - break - } + if matches := rule.Header.Value.MatchString(header.Value); matches { + valueMatches = true + break } } // When only key or value is set, match on whatever is set. @@ -264,7 +246,7 @@ func (reqLog RequestLog) MatchScope(s *scope.Scope) bool { } if rule.Body != nil { - if matches := rule.Body.Match(reqLog.Body); matches { + if matches := rule.Body.Match(reqLog.GetRequest().GetBody()); matches { return true } } diff --git a/pkg/reqlog/search_test.go b/pkg/reqlog/search_test.go index ae14c9f..c044324 100644 --- a/pkg/reqlog/search_test.go +++ b/pkg/reqlog/search_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/dstotijn/hetty/pkg/filter" + "github.com/dstotijn/hetty/pkg/http" "github.com/dstotijn/hetty/pkg/reqlog" ) @@ -13,15 +14,17 @@ func TestRequestLogMatch(t *testing.T) { tests := []struct { name string query string - requestLog reqlog.RequestLog + requestLog *reqlog.HttpRequestLog expectedMatch bool expectedError error }{ { name: "infix expression, equal operator, match", query: "req.body = foo", - requestLog: reqlog.RequestLog{ - Body: []byte("foo"), + requestLog: &reqlog.HttpRequestLog{ + Request: &http.Request{ + Body: []byte("foo"), + }, }, expectedMatch: true, expectedError: nil, @@ -29,8 +32,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "infix expression, not equal operator, match", query: "req.body != bar", - requestLog: reqlog.RequestLog{ - Body: []byte("foo"), + requestLog: &reqlog.HttpRequestLog{ + Request: &http.Request{ + Body: []byte("foo"), + }, }, expectedMatch: true, expectedError: nil, @@ -38,8 +43,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "infix expression, greater than operator, match", query: "req.body > a", - requestLog: reqlog.RequestLog{ - Body: []byte("b"), + requestLog: &reqlog.HttpRequestLog{ + Request: &http.Request{ + Body: []byte("b"), + }, }, expectedMatch: true, expectedError: nil, @@ -47,8 +54,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "infix expression, less than operator, match", query: "req.body < b", - requestLog: reqlog.RequestLog{ - Body: []byte("a"), + requestLog: &reqlog.HttpRequestLog{ + Request: &http.Request{ + Body: []byte("a"), + }, }, expectedMatch: true, expectedError: nil, @@ -56,8 +65,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "infix expression, greater than or equal operator, match greater than", query: "req.body >= a", - requestLog: reqlog.RequestLog{ - Body: []byte("b"), + requestLog: &reqlog.HttpRequestLog{ + Request: &http.Request{ + Body: []byte("b"), + }, }, expectedMatch: true, expectedError: nil, @@ -65,8 +76,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "infix expression, greater than or equal operator, match equal", query: "req.body >= a", - requestLog: reqlog.RequestLog{ - Body: []byte("a"), + requestLog: &reqlog.HttpRequestLog{ + Request: &http.Request{ + Body: []byte("a"), + }, }, expectedMatch: true, expectedError: nil, @@ -74,8 +87,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "infix expression, less than or equal operator, match less than", query: "req.body <= b", - requestLog: reqlog.RequestLog{ - Body: []byte("a"), + requestLog: &reqlog.HttpRequestLog{ + Request: &http.Request{ + Body: []byte("a"), + }, }, expectedMatch: true, expectedError: nil, @@ -83,8 +98,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "infix expression, less than or equal operator, match equal", query: "req.body <= b", - requestLog: reqlog.RequestLog{ - Body: []byte("b"), + requestLog: &reqlog.HttpRequestLog{ + Request: &http.Request{ + Body: []byte("b"), + }, }, expectedMatch: true, expectedError: nil, @@ -92,8 +109,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "infix expression, regular expression operator, match", query: `req.body =~ "^foo(.*)$"`, - requestLog: reqlog.RequestLog{ - Body: []byte("foobar"), + requestLog: &reqlog.HttpRequestLog{ + Request: &http.Request{ + Body: []byte("foobar"), + }, }, expectedMatch: true, expectedError: nil, @@ -101,8 +120,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "infix expression, negate regular expression operator, match", query: `req.body !~ "^foo(.*)$"`, - requestLog: reqlog.RequestLog{ - Body: []byte("xoobar"), + requestLog: &reqlog.HttpRequestLog{ + Request: &http.Request{ + Body: []byte("xoobar"), + }, }, expectedMatch: true, expectedError: nil, @@ -110,9 +131,11 @@ func TestRequestLogMatch(t *testing.T) { { name: "infix expression, and operator, match", query: "req.body = bar AND res.body = yolo", - requestLog: reqlog.RequestLog{ - Body: []byte("bar"), - Response: &reqlog.ResponseLog{ + requestLog: &reqlog.HttpRequestLog{ + Request: &http.Request{ + Body: []byte("bar"), + }, + Response: &http.Response{ Body: []byte("yolo"), }, }, @@ -122,9 +145,11 @@ func TestRequestLogMatch(t *testing.T) { { name: "infix expression, or operator, match", query: "req.body = bar OR res.body = yolo", - requestLog: reqlog.RequestLog{ - Body: []byte("foo"), - Response: &reqlog.ResponseLog{ + requestLog: &reqlog.HttpRequestLog{ + Request: &http.Request{ + Body: []byte("foo"), + }, + Response: &http.Response{ Body: []byte("yolo"), }, }, @@ -134,8 +159,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "prefix expression, not operator, match", query: "NOT (req.body = bar)", - requestLog: reqlog.RequestLog{ - Body: []byte("foo"), + requestLog: &reqlog.HttpRequestLog{ + Request: &http.Request{ + Body: []byte("foo"), + }, }, expectedMatch: true, expectedError: nil, @@ -143,8 +170,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "string literal expression, match in request log", query: "foo", - requestLog: reqlog.RequestLog{ - Body: []byte("foo"), + requestLog: &reqlog.HttpRequestLog{ + Request: &http.Request{ + Body: []byte("foo"), + }, }, expectedMatch: true, expectedError: nil, @@ -152,8 +181,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "string literal expression, no match", query: "foo", - requestLog: reqlog.RequestLog{ - Body: []byte("bar"), + requestLog: &reqlog.HttpRequestLog{ + Request: &http.Request{ + Body: []byte("bar"), + }, }, expectedMatch: false, expectedError: nil, @@ -161,8 +192,8 @@ func TestRequestLogMatch(t *testing.T) { { name: "string literal expression, match in response log", query: "foo", - requestLog: reqlog.RequestLog{ - Response: &reqlog.ResponseLog{ + requestLog: &reqlog.HttpRequestLog{ + Response: &http.Response{ Body: []byte("foo"), }, }, diff --git a/pkg/scope/scope.pb.go b/pkg/scope/scope.pb.go new file mode 100644 index 0000000..4218634 --- /dev/null +++ b/pkg/scope/scope.pb.go @@ -0,0 +1,159 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.3 +// protoc (unknown) +// source: scope/scope.proto + +package scope + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ScopeRule struct { + state protoimpl.MessageState `protogen:"open.v1"` + UrlRegexp string `protobuf:"bytes,1,opt,name=url_regexp,json=urlRegexp,proto3" json:"url_regexp,omitempty"` + HeaderKeyRegexp string `protobuf:"bytes,2,opt,name=header_key_regexp,json=headerKeyRegexp,proto3" json:"header_key_regexp,omitempty"` + HeaderValueRegexp string `protobuf:"bytes,3,opt,name=header_value_regexp,json=headerValueRegexp,proto3" json:"header_value_regexp,omitempty"` + BodyRegexp string `protobuf:"bytes,4,opt,name=body_regexp,json=bodyRegexp,proto3" json:"body_regexp,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ScopeRule) Reset() { + *x = ScopeRule{} + mi := &file_scope_scope_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ScopeRule) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ScopeRule) ProtoMessage() {} + +func (x *ScopeRule) ProtoReflect() protoreflect.Message { + mi := &file_scope_scope_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ScopeRule.ProtoReflect.Descriptor instead. +func (*ScopeRule) Descriptor() ([]byte, []int) { + return file_scope_scope_proto_rawDescGZIP(), []int{0} +} + +func (x *ScopeRule) GetUrlRegexp() string { + if x != nil { + return x.UrlRegexp + } + return "" +} + +func (x *ScopeRule) GetHeaderKeyRegexp() string { + if x != nil { + return x.HeaderKeyRegexp + } + return "" +} + +func (x *ScopeRule) GetHeaderValueRegexp() string { + if x != nil { + return x.HeaderValueRegexp + } + return "" +} + +func (x *ScopeRule) GetBodyRegexp() string { + if x != nil { + return x.BodyRegexp + } + return "" +} + +var File_scope_scope_proto protoreflect.FileDescriptor + +var file_scope_scope_proto_rawDesc = []byte{ + 0x0a, 0x11, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x2f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x73, 0x63, 0x6f, 0x70, 0x65, + 0x2e, 0x76, 0x31, 0x22, 0xa7, 0x01, 0x0a, 0x09, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x52, 0x75, 0x6c, + 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x72, 0x6c, 0x5f, 0x72, 0x65, 0x67, 0x65, 0x78, 0x70, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x75, 0x72, 0x6c, 0x52, 0x65, 0x67, 0x65, 0x78, 0x70, + 0x12, 0x2a, 0x0a, 0x11, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x72, + 0x65, 0x67, 0x65, 0x78, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x68, 0x65, 0x61, + 0x64, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x67, 0x65, 0x78, 0x70, 0x12, 0x2e, 0x0a, 0x13, + 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x72, 0x65, 0x67, + 0x65, 0x78, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x68, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x65, 0x67, 0x65, 0x78, 0x70, 0x12, 0x1f, 0x0a, 0x0b, + 0x62, 0x6f, 0x64, 0x79, 0x5f, 0x72, 0x65, 0x67, 0x65, 0x78, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x62, 0x6f, 0x64, 0x79, 0x52, 0x65, 0x67, 0x65, 0x78, 0x70, 0x42, 0x25, 0x5a, + 0x23, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x73, 0x74, 0x6f, + 0x74, 0x69, 0x6a, 0x6e, 0x2f, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x73, + 0x63, 0x6f, 0x70, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_scope_scope_proto_rawDescOnce sync.Once + file_scope_scope_proto_rawDescData = file_scope_scope_proto_rawDesc +) + +func file_scope_scope_proto_rawDescGZIP() []byte { + file_scope_scope_proto_rawDescOnce.Do(func() { + file_scope_scope_proto_rawDescData = protoimpl.X.CompressGZIP(file_scope_scope_proto_rawDescData) + }) + return file_scope_scope_proto_rawDescData +} + +var file_scope_scope_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_scope_scope_proto_goTypes = []any{ + (*ScopeRule)(nil), // 0: hetty.scope.v1.ScopeRule +} +var file_scope_scope_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_scope_scope_proto_init() } +func file_scope_scope_proto_init() { + if File_scope_scope_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_scope_scope_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_scope_scope_proto_goTypes, + DependencyIndexes: file_scope_scope_proto_depIdxs, + MessageInfos: file_scope_scope_proto_msgTypes, + }.Build() + File_scope_scope_proto = out.File + file_scope_scope_proto_rawDesc = nil + file_scope_scope_proto_goTypes = nil + file_scope_scope_proto_depIdxs = nil +} diff --git a/pkg/sender/repo.go b/pkg/sender/repo.go index 32cbcad..8f653f7 100644 --- a/pkg/sender/repo.go +++ b/pkg/sender/repo.go @@ -2,15 +2,11 @@ package sender import ( "context" - - "github.com/oklog/ulid" - - "github.com/dstotijn/hetty/pkg/scope" ) type Repository interface { - FindSenderRequestByID(ctx context.Context, projectID, id ulid.ULID) (Request, error) - FindSenderRequests(ctx context.Context, filter FindRequestsFilter, scope *scope.Scope) ([]Request, error) - StoreSenderRequest(ctx context.Context, req Request) error - DeleteSenderRequests(ctx context.Context, projectID ulid.ULID) error + FindSenderRequestByID(ctx context.Context, projectID, id string) (*Request, error) + FindSenderRequests(ctx context.Context, projectID string, filterFn func(*Request) (bool, error)) ([]*Request, error) + StoreSenderRequest(ctx context.Context, req *Request) error + DeleteSenderRequests(ctx context.Context, projectID string) error } diff --git a/pkg/sender/search.go b/pkg/sender/search.go index c7c5b63..c9660ed 100644 --- a/pkg/sender/search.go +++ b/pkg/sender/search.go @@ -5,31 +5,32 @@ import ( "fmt" "strings" - "github.com/oklog/ulid" + "github.com/oklog/ulid/v2" "github.com/dstotijn/hetty/pkg/filter" - "github.com/dstotijn/hetty/pkg/reqlog" + "github.com/dstotijn/hetty/pkg/http" "github.com/dstotijn/hetty/pkg/scope" ) -var senderReqSearchKeyFns = map[string]func(req Request) string{ - "req.id": func(req Request) string { return req.ID.String() }, - "req.proto": func(req Request) string { return req.Proto }, - "req.url": func(req Request) string { - if req.URL == nil { +var senderReqSearchKeyFns = map[string]func(req *Request) string{ + "req.id": func(req *Request) string { return req.Id }, + "req.proto": func(req *Request) string { return req.GetHttpRequest().GetProtocol().String() }, + "req.url": func(req *Request) string { return req.GetHttpRequest().GetUrl() }, + "req.method": func(req *Request) string { return req.GetHttpRequest().GetMethod().String() }, + "req.body": func(req *Request) string { return string(req.GetHttpRequest().GetBody()) }, + "req.timestamp": func(req *Request) string { + id, err := ulid.Parse(req.Id) + if err != nil { return "" } - return req.URL.String() + return ulid.Time(id.Time()).String() }, - "req.method": func(req Request) string { return req.Method }, - "req.body": func(req Request) string { return string(req.Body) }, - "req.timestamp": func(req Request) string { return ulid.Time(req.ID.Time()).String() }, } // TODO: Request and response headers search key functions. // Matches returns true if the supplied search expression evaluates to true. -func (req Request) Matches(expr filter.Expression) (bool, error) { +func (req *Request) Matches(expr filter.Expression) (bool, error) { switch e := expr.(type) { case filter.PrefixExpression: return req.matchPrefixExpr(e) @@ -42,7 +43,7 @@ func (req Request) Matches(expr filter.Expression) (bool, error) { } } -func (req Request) matchPrefixExpr(expr filter.PrefixExpression) (bool, error) { +func (req *Request) matchPrefixExpr(expr filter.PrefixExpression) (bool, error) { switch expr.Operator { case filter.TokOpNot: match, err := req.Matches(expr.Right) @@ -56,7 +57,7 @@ func (req Request) matchPrefixExpr(expr filter.PrefixExpression) (bool, error) { } } -func (req Request) matchInfixExpr(expr filter.InfixExpression) (bool, error) { +func (req *Request) matchInfixExpr(expr filter.InfixExpression) (bool, error) { switch expr.Operator { case filter.TokOpAnd: left, err := req.Matches(expr.Left) @@ -92,7 +93,7 @@ func (req Request) matchInfixExpr(expr filter.InfixExpression) (bool, error) { leftVal := req.getMappedStringLiteral(left.Value) if leftVal == "req.headers" { - match, err := filter.MatchHTTPHeaders(expr.Operator, expr.Right, req.Header) + match, err := filter.MatchHTTPHeaders(expr.Operator, expr.Right, req.GetHttpRequest().GetHeaders()) if err != nil { return false, fmt.Errorf("failed to match request HTTP headers: %w", err) } @@ -100,8 +101,8 @@ func (req Request) matchInfixExpr(expr filter.InfixExpression) (bool, error) { return match, nil } - if leftVal == "res.headers" && req.Response != nil { - match, err := filter.MatchHTTPHeaders(expr.Operator, expr.Right, req.Response.Header) + if leftVal == "res.headers" && req.GetHttpResponse() != nil { + match, err := filter.MatchHTTPHeaders(expr.Operator, expr.Right, req.GetHttpResponse().GetHeaders()) if err != nil { return false, fmt.Errorf("failed to match response HTTP headers: %w", err) } @@ -152,7 +153,7 @@ func (req Request) matchInfixExpr(expr filter.InfixExpression) (bool, error) { } } -func (req Request) getMappedStringLiteral(s string) string { +func (req *Request) getMappedStringLiteral(s string) string { switch { case strings.HasPrefix(s, "req."): fn, ok := senderReqSearchKeyFns[s] @@ -160,28 +161,22 @@ func (req Request) getMappedStringLiteral(s string) string { return fn(req) } case strings.HasPrefix(s, "res."): - if req.Response == nil { - return "" - } - - fn, ok := reqlog.ResLogSearchKeyFns[s] + fn, ok := http.ResponseSearchKeyFns[s] if ok { - return fn(*req.Response) + return fn(req.GetHttpResponse()) } } return s } -func (req Request) matchStringLiteral(strLiteral filter.StringLiteral) (bool, error) { - for key, values := range req.Header { - for _, value := range values { - if strings.Contains( - strings.ToLower(fmt.Sprintf("%v: %v", key, value)), - strings.ToLower(strLiteral.Value), - ) { - return true, nil - } +func (req *Request) matchStringLiteral(strLiteral filter.StringLiteral) (bool, error) { + for _, header := range req.GetHttpRequest().GetHeaders() { + if strings.Contains( + strings.ToLower(fmt.Sprintf("%v: %v", header.Key, header.Value)), + strings.ToLower(strLiteral.Value), + ) { + return true, nil } } @@ -194,54 +189,47 @@ func (req Request) matchStringLiteral(strLiteral filter.StringLiteral) (bool, er } } - if req.Response != nil { - for key, values := range req.Response.Header { - for _, value := range values { - if strings.Contains( - strings.ToLower(fmt.Sprintf("%v: %v", key, value)), - strings.ToLower(strLiteral.Value), - ) { - return true, nil - } - } + for _, header := range req.GetHttpResponse().GetHeaders() { + if strings.Contains( + strings.ToLower(fmt.Sprintf("%v: %v", header.Key, header.Value)), + strings.ToLower(strLiteral.Value), + ) { + return true, nil } + } - for _, fn := range reqlog.ResLogSearchKeyFns { - if strings.Contains( - strings.ToLower(fn(*req.Response)), - strings.ToLower(strLiteral.Value), - ) { - return true, nil - } + for _, fn := range http.ResponseSearchKeyFns { + if strings.Contains( + strings.ToLower(fn(req.GetHttpResponse())), + strings.ToLower(strLiteral.Value), + ) { + return true, nil } } return false, nil } -func (req Request) MatchScope(s *scope.Scope) bool { +func (req *Request) MatchScope(s *scope.Scope) bool { for _, rule := range s.Rules() { - if rule.URL != nil && req.URL != nil { - if matches := rule.URL.MatchString(req.URL.String()); matches { + if url := req.GetHttpRequest().GetUrl(); rule.URL != nil && url != "" { + if matches := rule.URL.MatchString(url); matches { return true } } - for key, values := range req.Header { + for _, headers := range req.GetHttpRequest().GetHeaders() { var keyMatches, valueMatches bool if rule.Header.Key != nil { - if matches := rule.Header.Key.MatchString(key); matches { + if matches := rule.Header.Key.MatchString(headers.Key); matches { keyMatches = true } } if rule.Header.Value != nil { - for _, value := range values { - if matches := rule.Header.Value.MatchString(value); matches { - valueMatches = true - break - } + if matches := rule.Header.Value.MatchString(headers.Value); matches { + valueMatches = true } } // When only key or value is set, match on whatever is set. @@ -257,7 +245,7 @@ func (req Request) MatchScope(s *scope.Scope) bool { } if rule.Body != nil { - if matches := rule.Body.Match(req.Body); matches { + if matches := rule.Body.Match(req.GetHttpRequest().GetBody()); matches { return true } } diff --git a/pkg/sender/search_test.go b/pkg/sender/search_test.go index d1e179f..5f824b5 100644 --- a/pkg/sender/search_test.go +++ b/pkg/sender/search_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/dstotijn/hetty/pkg/filter" - "github.com/dstotijn/hetty/pkg/reqlog" + "github.com/dstotijn/hetty/pkg/http" "github.com/dstotijn/hetty/pkg/sender" ) @@ -14,15 +14,17 @@ func TestRequestLogMatch(t *testing.T) { tests := []struct { name string query string - senderReq sender.Request + senderReq *sender.Request expectedMatch bool expectedError error }{ { name: "infix expression, equal operator, match", query: "req.body = foo", - senderReq: sender.Request{ - Body: []byte("foo"), + senderReq: &sender.Request{ + HttpRequest: &http.Request{ + Body: []byte("foo"), + }, }, expectedMatch: true, expectedError: nil, @@ -30,8 +32,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "infix expression, not equal operator, match", query: "req.body != bar", - senderReq: sender.Request{ - Body: []byte("foo"), + senderReq: &sender.Request{ + HttpRequest: &http.Request{ + Body: []byte("foo"), + }, }, expectedMatch: true, expectedError: nil, @@ -39,8 +43,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "infix expression, greater than operator, match", query: "req.body > a", - senderReq: sender.Request{ - Body: []byte("b"), + senderReq: &sender.Request{ + HttpRequest: &http.Request{ + Body: []byte("b"), + }, }, expectedMatch: true, expectedError: nil, @@ -48,8 +54,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "infix expression, less than operator, match", query: "req.body < b", - senderReq: sender.Request{ - Body: []byte("a"), + senderReq: &sender.Request{ + HttpRequest: &http.Request{ + Body: []byte("a"), + }, }, expectedMatch: true, expectedError: nil, @@ -57,8 +65,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "infix expression, greater than or equal operator, match greater than", query: "req.body >= a", - senderReq: sender.Request{ - Body: []byte("b"), + senderReq: &sender.Request{ + HttpRequest: &http.Request{ + Body: []byte("b"), + }, }, expectedMatch: true, expectedError: nil, @@ -66,8 +76,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "infix expression, greater than or equal operator, match equal", query: "req.body >= a", - senderReq: sender.Request{ - Body: []byte("a"), + senderReq: &sender.Request{ + HttpRequest: &http.Request{ + Body: []byte("a"), + }, }, expectedMatch: true, expectedError: nil, @@ -75,8 +87,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "infix expression, less than or equal operator, match less than", query: "req.body <= b", - senderReq: sender.Request{ - Body: []byte("a"), + senderReq: &sender.Request{ + HttpRequest: &http.Request{ + Body: []byte("a"), + }, }, expectedMatch: true, expectedError: nil, @@ -84,8 +98,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "infix expression, less than or equal operator, match equal", query: "req.body <= b", - senderReq: sender.Request{ - Body: []byte("b"), + senderReq: &sender.Request{ + HttpRequest: &http.Request{ + Body: []byte("b"), + }, }, expectedMatch: true, expectedError: nil, @@ -93,8 +109,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "infix expression, regular expression operator, match", query: `req.body =~ "^foo(.*)$"`, - senderReq: sender.Request{ - Body: []byte("foobar"), + senderReq: &sender.Request{ + HttpRequest: &http.Request{ + Body: []byte("foobar"), + }, }, expectedMatch: true, expectedError: nil, @@ -102,8 +120,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "infix expression, negate regular expression operator, match", query: `req.body !~ "^foo(.*)$"`, - senderReq: sender.Request{ - Body: []byte("xoobar"), + senderReq: &sender.Request{ + HttpRequest: &http.Request{ + Body: []byte("xoobar"), + }, }, expectedMatch: true, expectedError: nil, @@ -111,9 +131,11 @@ func TestRequestLogMatch(t *testing.T) { { name: "infix expression, and operator, match", query: "req.body = bar AND res.body = yolo", - senderReq: sender.Request{ - Body: []byte("bar"), - Response: &reqlog.ResponseLog{ + senderReq: &sender.Request{ + HttpRequest: &http.Request{ + Body: []byte("bar"), + }, + HttpResponse: &http.Response{ Body: []byte("yolo"), }, }, @@ -123,9 +145,11 @@ func TestRequestLogMatch(t *testing.T) { { name: "infix expression, or operator, match", query: "req.body = bar OR res.body = yolo", - senderReq: sender.Request{ - Body: []byte("foo"), - Response: &reqlog.ResponseLog{ + senderReq: &sender.Request{ + HttpRequest: &http.Request{ + Body: []byte("foo"), + }, + HttpResponse: &http.Response{ Body: []byte("yolo"), }, }, @@ -135,8 +159,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "prefix expression, not operator, match", query: "NOT (req.body = bar)", - senderReq: sender.Request{ - Body: []byte("foo"), + senderReq: &sender.Request{ + HttpRequest: &http.Request{ + Body: []byte("foo"), + }, }, expectedMatch: true, expectedError: nil, @@ -144,8 +170,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "string literal expression, match in request log", query: "foo", - senderReq: sender.Request{ - Body: []byte("foo"), + senderReq: &sender.Request{ + HttpRequest: &http.Request{ + Body: []byte("foo"), + }, }, expectedMatch: true, expectedError: nil, @@ -153,8 +181,10 @@ func TestRequestLogMatch(t *testing.T) { { name: "string literal expression, no match", query: "foo", - senderReq: sender.Request{ - Body: []byte("bar"), + senderReq: &sender.Request{ + HttpRequest: &http.Request{ + Body: []byte("bar"), + }, }, expectedMatch: false, expectedError: nil, @@ -162,8 +192,8 @@ func TestRequestLogMatch(t *testing.T) { { name: "string literal expression, match in response log", query: "foo", - senderReq: sender.Request{ - Response: &reqlog.ResponseLog{ + senderReq: &sender.Request{ + HttpResponse: &http.Response{ Body: []byte("foo"), }, }, diff --git a/pkg/sender/sender.connect.go b/pkg/sender/sender.connect.go new file mode 100644 index 0000000..3a6def1 --- /dev/null +++ b/pkg/sender/sender.connect.go @@ -0,0 +1,311 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: sender/sender.proto + +package sender + +import ( + connect "connectrpc.com/connect" + context "context" + errors "errors" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion1_13_0 + +const ( + // SenderServiceName is the fully-qualified name of the SenderService service. + SenderServiceName = "sender.SenderService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // SenderServiceGetRequestByIDProcedure is the fully-qualified name of the SenderService's + // GetRequestByID RPC. + SenderServiceGetRequestByIDProcedure = "/sender.SenderService/GetRequestByID" + // SenderServiceListRequestsProcedure is the fully-qualified name of the SenderService's + // ListRequests RPC. + SenderServiceListRequestsProcedure = "/sender.SenderService/ListRequests" + // SenderServiceSetRequestsFilterProcedure is the fully-qualified name of the SenderService's + // SetRequestsFilter RPC. + SenderServiceSetRequestsFilterProcedure = "/sender.SenderService/SetRequestsFilter" + // SenderServiceGetRequestsFilterProcedure is the fully-qualified name of the SenderService's + // GetRequestsFilter RPC. + SenderServiceGetRequestsFilterProcedure = "/sender.SenderService/GetRequestsFilter" + // SenderServiceCreateOrUpdateRequestProcedure is the fully-qualified name of the SenderService's + // CreateOrUpdateRequest RPC. + SenderServiceCreateOrUpdateRequestProcedure = "/sender.SenderService/CreateOrUpdateRequest" + // SenderServiceCloneFromRequestLogProcedure is the fully-qualified name of the SenderService's + // CloneFromRequestLog RPC. + SenderServiceCloneFromRequestLogProcedure = "/sender.SenderService/CloneFromRequestLog" + // SenderServiceSendRequestProcedure is the fully-qualified name of the SenderService's SendRequest + // RPC. + SenderServiceSendRequestProcedure = "/sender.SenderService/SendRequest" + // SenderServiceDeleteRequestsProcedure is the fully-qualified name of the SenderService's + // DeleteRequests RPC. + SenderServiceDeleteRequestsProcedure = "/sender.SenderService/DeleteRequests" +) + +// SenderServiceClient is a client for the sender.SenderService service. +type SenderServiceClient interface { + GetRequestByID(context.Context, *connect.Request[GetRequestByIDRequest]) (*connect.Response[GetRequestByIDResponse], error) + ListRequests(context.Context, *connect.Request[ListRequestsRequest]) (*connect.Response[ListRequestsResponse], error) + SetRequestsFilter(context.Context, *connect.Request[SetRequestsFilterRequest]) (*connect.Response[SetRequestsFilterResponse], error) + GetRequestsFilter(context.Context, *connect.Request[GetRequestsFilterRequest]) (*connect.Response[GetRequestsFilterResponse], error) + CreateOrUpdateRequest(context.Context, *connect.Request[CreateOrUpdateRequestRequest]) (*connect.Response[CreateOrUpdateRequestResponse], error) + CloneFromRequestLog(context.Context, *connect.Request[CloneFromRequestLogRequest]) (*connect.Response[CloneFromRequestLogResponse], error) + SendRequest(context.Context, *connect.Request[SendRequestRequest]) (*connect.Response[SendRequestResponse], error) + DeleteRequests(context.Context, *connect.Request[DeleteRequestsRequest]) (*connect.Response[DeleteRequestsResponse], error) +} + +// NewSenderServiceClient constructs a client for the sender.SenderService service. By default, it +// uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends +// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or +// connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewSenderServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) SenderServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + senderServiceMethods := File_sender_sender_proto.Services().ByName("SenderService").Methods() + return &senderServiceClient{ + getRequestByID: connect.NewClient[GetRequestByIDRequest, GetRequestByIDResponse]( + httpClient, + baseURL+SenderServiceGetRequestByIDProcedure, + connect.WithSchema(senderServiceMethods.ByName("GetRequestByID")), + connect.WithClientOptions(opts...), + ), + listRequests: connect.NewClient[ListRequestsRequest, ListRequestsResponse]( + httpClient, + baseURL+SenderServiceListRequestsProcedure, + connect.WithSchema(senderServiceMethods.ByName("ListRequests")), + connect.WithClientOptions(opts...), + ), + setRequestsFilter: connect.NewClient[SetRequestsFilterRequest, SetRequestsFilterResponse]( + httpClient, + baseURL+SenderServiceSetRequestsFilterProcedure, + connect.WithSchema(senderServiceMethods.ByName("SetRequestsFilter")), + connect.WithClientOptions(opts...), + ), + getRequestsFilter: connect.NewClient[GetRequestsFilterRequest, GetRequestsFilterResponse]( + httpClient, + baseURL+SenderServiceGetRequestsFilterProcedure, + connect.WithSchema(senderServiceMethods.ByName("GetRequestsFilter")), + connect.WithClientOptions(opts...), + ), + createOrUpdateRequest: connect.NewClient[CreateOrUpdateRequestRequest, CreateOrUpdateRequestResponse]( + httpClient, + baseURL+SenderServiceCreateOrUpdateRequestProcedure, + connect.WithSchema(senderServiceMethods.ByName("CreateOrUpdateRequest")), + connect.WithClientOptions(opts...), + ), + cloneFromRequestLog: connect.NewClient[CloneFromRequestLogRequest, CloneFromRequestLogResponse]( + httpClient, + baseURL+SenderServiceCloneFromRequestLogProcedure, + connect.WithSchema(senderServiceMethods.ByName("CloneFromRequestLog")), + connect.WithClientOptions(opts...), + ), + sendRequest: connect.NewClient[SendRequestRequest, SendRequestResponse]( + httpClient, + baseURL+SenderServiceSendRequestProcedure, + connect.WithSchema(senderServiceMethods.ByName("SendRequest")), + connect.WithClientOptions(opts...), + ), + deleteRequests: connect.NewClient[DeleteRequestsRequest, DeleteRequestsResponse]( + httpClient, + baseURL+SenderServiceDeleteRequestsProcedure, + connect.WithSchema(senderServiceMethods.ByName("DeleteRequests")), + connect.WithClientOptions(opts...), + ), + } +} + +// senderServiceClient implements SenderServiceClient. +type senderServiceClient struct { + getRequestByID *connect.Client[GetRequestByIDRequest, GetRequestByIDResponse] + listRequests *connect.Client[ListRequestsRequest, ListRequestsResponse] + setRequestsFilter *connect.Client[SetRequestsFilterRequest, SetRequestsFilterResponse] + getRequestsFilter *connect.Client[GetRequestsFilterRequest, GetRequestsFilterResponse] + createOrUpdateRequest *connect.Client[CreateOrUpdateRequestRequest, CreateOrUpdateRequestResponse] + cloneFromRequestLog *connect.Client[CloneFromRequestLogRequest, CloneFromRequestLogResponse] + sendRequest *connect.Client[SendRequestRequest, SendRequestResponse] + deleteRequests *connect.Client[DeleteRequestsRequest, DeleteRequestsResponse] +} + +// GetRequestByID calls sender.SenderService.GetRequestByID. +func (c *senderServiceClient) GetRequestByID(ctx context.Context, req *connect.Request[GetRequestByIDRequest]) (*connect.Response[GetRequestByIDResponse], error) { + return c.getRequestByID.CallUnary(ctx, req) +} + +// ListRequests calls sender.SenderService.ListRequests. +func (c *senderServiceClient) ListRequests(ctx context.Context, req *connect.Request[ListRequestsRequest]) (*connect.Response[ListRequestsResponse], error) { + return c.listRequests.CallUnary(ctx, req) +} + +// SetRequestsFilter calls sender.SenderService.SetRequestsFilter. +func (c *senderServiceClient) SetRequestsFilter(ctx context.Context, req *connect.Request[SetRequestsFilterRequest]) (*connect.Response[SetRequestsFilterResponse], error) { + return c.setRequestsFilter.CallUnary(ctx, req) +} + +// GetRequestsFilter calls sender.SenderService.GetRequestsFilter. +func (c *senderServiceClient) GetRequestsFilter(ctx context.Context, req *connect.Request[GetRequestsFilterRequest]) (*connect.Response[GetRequestsFilterResponse], error) { + return c.getRequestsFilter.CallUnary(ctx, req) +} + +// CreateOrUpdateRequest calls sender.SenderService.CreateOrUpdateRequest. +func (c *senderServiceClient) CreateOrUpdateRequest(ctx context.Context, req *connect.Request[CreateOrUpdateRequestRequest]) (*connect.Response[CreateOrUpdateRequestResponse], error) { + return c.createOrUpdateRequest.CallUnary(ctx, req) +} + +// CloneFromRequestLog calls sender.SenderService.CloneFromRequestLog. +func (c *senderServiceClient) CloneFromRequestLog(ctx context.Context, req *connect.Request[CloneFromRequestLogRequest]) (*connect.Response[CloneFromRequestLogResponse], error) { + return c.cloneFromRequestLog.CallUnary(ctx, req) +} + +// SendRequest calls sender.SenderService.SendRequest. +func (c *senderServiceClient) SendRequest(ctx context.Context, req *connect.Request[SendRequestRequest]) (*connect.Response[SendRequestResponse], error) { + return c.sendRequest.CallUnary(ctx, req) +} + +// DeleteRequests calls sender.SenderService.DeleteRequests. +func (c *senderServiceClient) DeleteRequests(ctx context.Context, req *connect.Request[DeleteRequestsRequest]) (*connect.Response[DeleteRequestsResponse], error) { + return c.deleteRequests.CallUnary(ctx, req) +} + +// SenderServiceHandler is an implementation of the sender.SenderService service. +type SenderServiceHandler interface { + GetRequestByID(context.Context, *connect.Request[GetRequestByIDRequest]) (*connect.Response[GetRequestByIDResponse], error) + ListRequests(context.Context, *connect.Request[ListRequestsRequest]) (*connect.Response[ListRequestsResponse], error) + SetRequestsFilter(context.Context, *connect.Request[SetRequestsFilterRequest]) (*connect.Response[SetRequestsFilterResponse], error) + GetRequestsFilter(context.Context, *connect.Request[GetRequestsFilterRequest]) (*connect.Response[GetRequestsFilterResponse], error) + CreateOrUpdateRequest(context.Context, *connect.Request[CreateOrUpdateRequestRequest]) (*connect.Response[CreateOrUpdateRequestResponse], error) + CloneFromRequestLog(context.Context, *connect.Request[CloneFromRequestLogRequest]) (*connect.Response[CloneFromRequestLogResponse], error) + SendRequest(context.Context, *connect.Request[SendRequestRequest]) (*connect.Response[SendRequestResponse], error) + DeleteRequests(context.Context, *connect.Request[DeleteRequestsRequest]) (*connect.Response[DeleteRequestsResponse], error) +} + +// NewSenderServiceHandler builds an HTTP handler from the service implementation. It returns the +// path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewSenderServiceHandler(svc SenderServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + senderServiceMethods := File_sender_sender_proto.Services().ByName("SenderService").Methods() + senderServiceGetRequestByIDHandler := connect.NewUnaryHandler( + SenderServiceGetRequestByIDProcedure, + svc.GetRequestByID, + connect.WithSchema(senderServiceMethods.ByName("GetRequestByID")), + connect.WithHandlerOptions(opts...), + ) + senderServiceListRequestsHandler := connect.NewUnaryHandler( + SenderServiceListRequestsProcedure, + svc.ListRequests, + connect.WithSchema(senderServiceMethods.ByName("ListRequests")), + connect.WithHandlerOptions(opts...), + ) + senderServiceSetRequestsFilterHandler := connect.NewUnaryHandler( + SenderServiceSetRequestsFilterProcedure, + svc.SetRequestsFilter, + connect.WithSchema(senderServiceMethods.ByName("SetRequestsFilter")), + connect.WithHandlerOptions(opts...), + ) + senderServiceGetRequestsFilterHandler := connect.NewUnaryHandler( + SenderServiceGetRequestsFilterProcedure, + svc.GetRequestsFilter, + connect.WithSchema(senderServiceMethods.ByName("GetRequestsFilter")), + connect.WithHandlerOptions(opts...), + ) + senderServiceCreateOrUpdateRequestHandler := connect.NewUnaryHandler( + SenderServiceCreateOrUpdateRequestProcedure, + svc.CreateOrUpdateRequest, + connect.WithSchema(senderServiceMethods.ByName("CreateOrUpdateRequest")), + connect.WithHandlerOptions(opts...), + ) + senderServiceCloneFromRequestLogHandler := connect.NewUnaryHandler( + SenderServiceCloneFromRequestLogProcedure, + svc.CloneFromRequestLog, + connect.WithSchema(senderServiceMethods.ByName("CloneFromRequestLog")), + connect.WithHandlerOptions(opts...), + ) + senderServiceSendRequestHandler := connect.NewUnaryHandler( + SenderServiceSendRequestProcedure, + svc.SendRequest, + connect.WithSchema(senderServiceMethods.ByName("SendRequest")), + connect.WithHandlerOptions(opts...), + ) + senderServiceDeleteRequestsHandler := connect.NewUnaryHandler( + SenderServiceDeleteRequestsProcedure, + svc.DeleteRequests, + connect.WithSchema(senderServiceMethods.ByName("DeleteRequests")), + connect.WithHandlerOptions(opts...), + ) + return "/sender.SenderService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case SenderServiceGetRequestByIDProcedure: + senderServiceGetRequestByIDHandler.ServeHTTP(w, r) + case SenderServiceListRequestsProcedure: + senderServiceListRequestsHandler.ServeHTTP(w, r) + case SenderServiceSetRequestsFilterProcedure: + senderServiceSetRequestsFilterHandler.ServeHTTP(w, r) + case SenderServiceGetRequestsFilterProcedure: + senderServiceGetRequestsFilterHandler.ServeHTTP(w, r) + case SenderServiceCreateOrUpdateRequestProcedure: + senderServiceCreateOrUpdateRequestHandler.ServeHTTP(w, r) + case SenderServiceCloneFromRequestLogProcedure: + senderServiceCloneFromRequestLogHandler.ServeHTTP(w, r) + case SenderServiceSendRequestProcedure: + senderServiceSendRequestHandler.ServeHTTP(w, r) + case SenderServiceDeleteRequestsProcedure: + senderServiceDeleteRequestsHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedSenderServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedSenderServiceHandler struct{} + +func (UnimplementedSenderServiceHandler) GetRequestByID(context.Context, *connect.Request[GetRequestByIDRequest]) (*connect.Response[GetRequestByIDResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("sender.SenderService.GetRequestByID is not implemented")) +} + +func (UnimplementedSenderServiceHandler) ListRequests(context.Context, *connect.Request[ListRequestsRequest]) (*connect.Response[ListRequestsResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("sender.SenderService.ListRequests is not implemented")) +} + +func (UnimplementedSenderServiceHandler) SetRequestsFilter(context.Context, *connect.Request[SetRequestsFilterRequest]) (*connect.Response[SetRequestsFilterResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("sender.SenderService.SetRequestsFilter is not implemented")) +} + +func (UnimplementedSenderServiceHandler) GetRequestsFilter(context.Context, *connect.Request[GetRequestsFilterRequest]) (*connect.Response[GetRequestsFilterResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("sender.SenderService.GetRequestsFilter is not implemented")) +} + +func (UnimplementedSenderServiceHandler) CreateOrUpdateRequest(context.Context, *connect.Request[CreateOrUpdateRequestRequest]) (*connect.Response[CreateOrUpdateRequestResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("sender.SenderService.CreateOrUpdateRequest is not implemented")) +} + +func (UnimplementedSenderServiceHandler) CloneFromRequestLog(context.Context, *connect.Request[CloneFromRequestLogRequest]) (*connect.Response[CloneFromRequestLogResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("sender.SenderService.CloneFromRequestLog is not implemented")) +} + +func (UnimplementedSenderServiceHandler) SendRequest(context.Context, *connect.Request[SendRequestRequest]) (*connect.Response[SendRequestResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("sender.SenderService.SendRequest is not implemented")) +} + +func (UnimplementedSenderServiceHandler) DeleteRequests(context.Context, *connect.Request[DeleteRequestsRequest]) (*connect.Response[DeleteRequestsResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("sender.SenderService.DeleteRequests is not implemented")) +} diff --git a/pkg/sender/sender.go b/pkg/sender/sender.go index 2d5377e..07abe87 100644 --- a/pkg/sender/sender.go +++ b/pkg/sender/sender.go @@ -5,21 +5,19 @@ import ( "context" "errors" "fmt" - "math/rand" "net/http" - "net/url" "time" - "github.com/oklog/ulid" + connect "connectrpc.com/connect" + "github.com/oklog/ulid/v2" + "google.golang.org/protobuf/proto" "github.com/dstotijn/hetty/pkg/filter" + httppb "github.com/dstotijn/hetty/pkg/http" "github.com/dstotijn/hetty/pkg/reqlog" "github.com/dstotijn/hetty/pkg/scope" ) -//nolint:gosec -var ulidEntropy = rand.New(rand.NewSource(time.Now().UnixNano())) - var defaultHTTPClient = &http.Client{ Transport: &HTTPTransport{}, Timeout: 30 * time.Second, @@ -31,20 +29,14 @@ var ( ) type Service struct { - activeProjectID ulid.ULID - findReqsFilter FindRequestsFilter + activeProjectID string + reqsFilter *RequestsFilter scope *scope.Scope repo Repository reqLogSvc *reqlog.Service httpClient *http.Client } -type FindRequestsFilter struct { - ProjectID ulid.ULID - OnlyInScope bool - SearchExpr filter.Expression -} - type Config struct { Scope *scope.Scope Repository Repository @@ -71,165 +63,215 @@ func NewService(cfg Config) *Service { return svc } -type Request struct { - ID ulid.ULID - ProjectID ulid.ULID - SourceRequestLogID ulid.ULID +func (svc *Service) GetRequestByID(ctx context.Context, req *connect.Request[GetRequestByIDRequest]) (*connect.Response[GetRequestByIDResponse], error) { + if svc.activeProjectID == "" { + return nil, connect.NewError(connect.CodeFailedPrecondition, ErrProjectIDMustBeSet) + } - URL *url.URL - Method string - Proto string - Header http.Header - Body []byte - - Response *reqlog.ResponseLog -} - -func (svc *Service) FindRequestByID(ctx context.Context, id ulid.ULID) (Request, error) { - req, err := svc.repo.FindSenderRequestByID(ctx, svc.activeProjectID, id) + senderReq, err := svc.repo.FindSenderRequestByID(ctx, svc.activeProjectID, req.Msg.RequestId) if err != nil { - return Request{}, fmt.Errorf("sender: failed to find request: %w", err) + return nil, connect.NewError(connect.CodeNotFound, fmt.Errorf("sender: failed to find request: %w", err)) } - return req, nil + return &connect.Response[GetRequestByIDResponse]{ + Msg: &GetRequestByIDResponse{Request: senderReq}, + }, nil } -func (svc *Service) FindRequests(ctx context.Context) ([]Request, error) { - return svc.repo.FindSenderRequests(ctx, svc.findReqsFilter, svc.scope) -} - -func (svc *Service) CreateOrUpdateRequest(ctx context.Context, req Request) (Request, error) { - if svc.activeProjectID.Compare(ulid.ULID{}) == 0 { - return Request{}, ErrProjectIDMustBeSet - } - - if req.ID.Compare(ulid.ULID{}) == 0 { - req.ID = ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) - } - - req.ProjectID = svc.activeProjectID - - if req.Method == "" { - req.Method = http.MethodGet - } - - if req.Proto == "" { - req.Proto = HTTPProto20 - } - - if !isValidProto(req.Proto) { - return Request{}, fmt.Errorf("sender: unsupported HTTP protocol: %v", req.Proto) - } - - err := svc.repo.StoreSenderRequest(ctx, req) +func (svc *Service) ListRequests(ctx context.Context, req *connect.Request[ListRequestsRequest]) (*connect.Response[ListRequestsResponse], error) { + reqs, err := svc.repo.FindSenderRequests(ctx, svc.activeProjectID, svc.filterRequest) if err != nil { - return Request{}, fmt.Errorf("sender: failed to store request: %w", err) + return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("sender: failed to find requests: %w", err)) } - return req, nil + return &connect.Response[ListRequestsResponse]{ + Msg: &ListRequestsResponse{Requests: reqs}, + }, nil } -func (svc *Service) CloneFromRequestLog(ctx context.Context, reqLogID ulid.ULID) (Request, error) { - if svc.activeProjectID.Compare(ulid.ULID{}) == 0 { - return Request{}, ErrProjectIDMustBeSet +func (svc *Service) filterRequest(req *Request) (bool, error) { + if svc.reqsFilter.OnlyInScope { + if svc.scope != nil && !req.MatchScope(svc.scope) { + return false, nil + } } - reqLog, err := svc.reqLogSvc.FindRequestLogByID(ctx, reqLogID) + if svc.reqsFilter.SearchExpr == "" { + return true, nil + } + + expr, err := filter.ParseQuery(svc.reqsFilter.SearchExpr) if err != nil { - return Request{}, fmt.Errorf("sender: failed to find request log: %w", err) + return false, fmt.Errorf("failed to parse search expression: %w", err) } - req := Request{ - ID: ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy), - ProjectID: svc.activeProjectID, - SourceRequestLogID: reqLogID, - Method: reqLog.Method, - URL: reqLog.URL, - Proto: HTTPProto20, // Attempt HTTP/2. - Header: reqLog.Header, - Body: reqLog.Body, - } - - err = svc.repo.StoreSenderRequest(ctx, req) + match, err := req.Matches(expr) if err != nil { - return Request{}, fmt.Errorf("sender: failed to store request: %w", err) + return false, fmt.Errorf("failed to match search expression for sender request (id: %v): %w", + req.Id, err, + ) } - return req, nil + return match, nil } -func (svc *Service) SetFindReqsFilter(filter FindRequestsFilter) { - svc.findReqsFilter = filter -} +func (svc *Service) CreateOrUpdateRequest(ctx context.Context, req *connect.Request[CreateOrUpdateRequestRequest]) (*connect.Response[CreateOrUpdateRequestResponse], error) { + if svc.activeProjectID == "" { + return nil, connect.NewError(connect.CodeFailedPrecondition, ErrProjectIDMustBeSet) + } -func (svc *Service) FindReqsFilter() FindRequestsFilter { - return svc.findReqsFilter -} + r := proto.Clone(req.Msg.Request).(*Request) -func (svc *Service) SendRequest(ctx context.Context, id ulid.ULID) (Request, error) { - req, err := svc.repo.FindSenderRequestByID(ctx, svc.activeProjectID, id) + if r == nil { + return nil, connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("sender: request is nil")) + } + + if r.HttpRequest == nil { + return nil, connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("sender: request.http_request is nil")) + } + + if r.Id == "" { + r.Id = ulid.Make().String() + } + + r.ProjectId = svc.activeProjectID + + if r.HttpRequest.Method == httppb.Method_METHOD_UNSPECIFIED { + r.HttpRequest.Method = httppb.Method_METHOD_GET + } + + if r.HttpRequest.Protocol == httppb.Protocol_PROTOCOL_UNSPECIFIED { + r.HttpRequest.Protocol = httppb.Protocol_PROTOCOL_HTTP20 + } + + err := svc.repo.StoreSenderRequest(ctx, r) if err != nil { - return Request{}, fmt.Errorf("sender: failed to find request: %w", err) + return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("sender: failed to store request: %w", err)) + } + + return &connect.Response[CreateOrUpdateRequestResponse]{ + Msg: &CreateOrUpdateRequestResponse{ + Request: r, + }, + }, nil +} + +func (svc *Service) CloneFromRequestLog(ctx context.Context, req *connect.Request[CloneFromRequestLogRequest]) (*connect.Response[CloneFromRequestLogResponse], error) { + if svc.activeProjectID == "" { + return nil, connect.NewError(connect.CodeFailedPrecondition, ErrProjectIDMustBeSet) + } + + reqLog, err := svc.reqLogSvc.FindRequestLogByID(ctx, req.Msg.RequestLogId) + if err != nil { + return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("sender: failed to find request log: %w", err)) + } + + clonedReqLog := proto.Clone(reqLog).(*reqlog.HttpRequestLog) + + senderReq := &Request{ + Id: ulid.Make().String(), + ProjectId: svc.activeProjectID, + SourceRequestLogId: clonedReqLog.Id, + HttpRequest: clonedReqLog.Request, + } + + err = svc.repo.StoreSenderRequest(ctx, senderReq) + if err != nil { + return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("sender: failed to store request: %w", err)) + } + + return &connect.Response[CloneFromRequestLogResponse]{Msg: &CloneFromRequestLogResponse{ + Request: senderReq, + }}, nil +} + +func (svc *Service) SetRequestsFilter(filter *RequestsFilter) { + svc.reqsFilter = filter +} + +func (svc *Service) RequestsFilter() *RequestsFilter { + return svc.reqsFilter +} + +func (svc *Service) SendRequest(ctx context.Context, connReq *connect.Request[SendRequestRequest]) (*connect.Response[SendRequestResponse], error) { + req, err := svc.repo.FindSenderRequestByID(ctx, svc.activeProjectID, connReq.Msg.RequestId) + if err != nil { + return nil, connect.NewError(connect.CodeNotFound, fmt.Errorf("sender: failed to find request: %w", err)) } httpReq, err := parseHTTPRequest(ctx, req) if err != nil { - return Request{}, fmt.Errorf("sender: failed to parse HTTP request: %w", err) + return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("sender: failed to parse HTTP request: %w", err)) } - resLog, err := svc.sendHTTPRequest(httpReq) + httpRes, err := svc.sendHTTPRequest(httpReq) if err != nil { - return Request{}, fmt.Errorf("sender: could not send HTTP request: %w", err) + return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("sender: could not send HTTP request: %w", err)) } - req.Response = &resLog + req.HttpResponse = httpRes err = svc.repo.StoreSenderRequest(ctx, req) if err != nil { - return Request{}, fmt.Errorf("sender: failed to store sender response log: %w", err) + return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("sender: failed to store sender response log: %w", err)) } - req.Response = &resLog - - return req, nil + return &connect.Response[SendRequestResponse]{ + Msg: &SendRequestResponse{ + Request: req, + }, + }, nil } -func parseHTTPRequest(ctx context.Context, req Request) (*http.Request, error) { - ctx = context.WithValue(ctx, protoCtxKey{}, req.Proto) +func parseHTTPRequest(ctx context.Context, req *Request) (*http.Request, error) { + ctx = context.WithValue(ctx, protoCtxKey{}, req.GetHttpRequest().GetProtocol()) - httpReq, err := http.NewRequestWithContext(ctx, req.Method, req.URL.String(), bytes.NewReader(req.Body)) + httpReq, err := http.NewRequestWithContext(ctx, + req.GetHttpRequest().GetMethod().String(), + req.GetHttpRequest().GetUrl(), + bytes.NewReader(req.GetHttpRequest().GetBody()), + ) if err != nil { return nil, fmt.Errorf("failed to construct HTTP request: %w", err) } - if req.Header != nil { - httpReq.Header = req.Header + for _, header := range req.GetHttpRequest().GetHeaders() { + httpReq.Header.Add(header.Key, header.Value) } return httpReq, nil } -func (svc *Service) sendHTTPRequest(httpReq *http.Request) (reqlog.ResponseLog, error) { +func (svc *Service) sendHTTPRequest(httpReq *http.Request) (*httppb.Response, error) { res, err := svc.httpClient.Do(httpReq) if err != nil { - return reqlog.ResponseLog{}, &SendError{err} + return nil, &SendError{err} } defer res.Body.Close() - resLog, err := reqlog.ParseHTTPResponse(res) + resLog, err := httppb.ParseHTTPResponse(res) if err != nil { - return reqlog.ResponseLog{}, fmt.Errorf("failed to parse http response: %w", err) + return nil, fmt.Errorf("failed to parse http response: %w", err) } return resLog, err } -func (svc *Service) SetActiveProjectID(id ulid.ULID) { +func (svc *Service) SetActiveProjectID(id string) { svc.activeProjectID = id } -func (svc *Service) DeleteRequests(ctx context.Context, projectID ulid.ULID) error { - return svc.repo.DeleteSenderRequests(ctx, projectID) +func (svc *Service) DeleteRequests(ctx context.Context, req *connect.Request[DeleteRequestsRequest]) (*connect.Response[DeleteRequestsResponse], error) { + if svc.activeProjectID == "" { + return nil, connect.NewError(connect.CodeFailedPrecondition, ErrProjectIDMustBeSet) + } + + err := svc.repo.DeleteSenderRequests(ctx, svc.activeProjectID) + if err != nil { + return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("sender: failed to delete requests: %w", err)) + } + + return &connect.Response[DeleteRequestsResponse]{}, nil } func (e SendError) Error() string { diff --git a/pkg/sender/sender.pb.go b/pkg/sender/sender.pb.go new file mode 100644 index 0000000..c68b576 --- /dev/null +++ b/pkg/sender/sender.pb.go @@ -0,0 +1,1040 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.3 +// protoc (unknown) +// source: sender/sender.proto + +package sender + +import ( + http "github.com/dstotijn/hetty/pkg/http" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Request struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + ProjectId string `protobuf:"bytes,2,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` + SourceRequestLogId string `protobuf:"bytes,3,opt,name=source_request_log_id,json=sourceRequestLogId,proto3" json:"source_request_log_id,omitempty"` + HttpRequest *http.Request `protobuf:"bytes,4,opt,name=http_request,json=httpRequest,proto3" json:"http_request,omitempty"` + HttpResponse *http.Response `protobuf:"bytes,10,opt,name=http_response,json=httpResponse,proto3" json:"http_response,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Request) Reset() { + *x = Request{} + mi := &file_sender_sender_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Request) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Request) ProtoMessage() {} + +func (x *Request) ProtoReflect() protoreflect.Message { + mi := &file_sender_sender_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Request.ProtoReflect.Descriptor instead. +func (*Request) Descriptor() ([]byte, []int) { + return file_sender_sender_proto_rawDescGZIP(), []int{0} +} + +func (x *Request) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *Request) GetProjectId() string { + if x != nil { + return x.ProjectId + } + return "" +} + +func (x *Request) GetSourceRequestLogId() string { + if x != nil { + return x.SourceRequestLogId + } + return "" +} + +func (x *Request) GetHttpRequest() *http.Request { + if x != nil { + return x.HttpRequest + } + return nil +} + +func (x *Request) GetHttpResponse() *http.Response { + if x != nil { + return x.HttpResponse + } + return nil +} + +type RequestsFilter struct { + state protoimpl.MessageState `protogen:"open.v1"` + OnlyInScope bool `protobuf:"varint,1,opt,name=only_in_scope,json=onlyInScope,proto3" json:"only_in_scope,omitempty"` + SearchExpr string `protobuf:"bytes,2,opt,name=search_expr,json=searchExpr,proto3" json:"search_expr,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RequestsFilter) Reset() { + *x = RequestsFilter{} + mi := &file_sender_sender_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RequestsFilter) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequestsFilter) ProtoMessage() {} + +func (x *RequestsFilter) ProtoReflect() protoreflect.Message { + mi := &file_sender_sender_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RequestsFilter.ProtoReflect.Descriptor instead. +func (*RequestsFilter) Descriptor() ([]byte, []int) { + return file_sender_sender_proto_rawDescGZIP(), []int{1} +} + +func (x *RequestsFilter) GetOnlyInScope() bool { + if x != nil { + return x.OnlyInScope + } + return false +} + +func (x *RequestsFilter) GetSearchExpr() string { + if x != nil { + return x.SearchExpr + } + return "" +} + +type GetRequestByIDRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetRequestByIDRequest) Reset() { + *x = GetRequestByIDRequest{} + mi := &file_sender_sender_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetRequestByIDRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRequestByIDRequest) ProtoMessage() {} + +func (x *GetRequestByIDRequest) ProtoReflect() protoreflect.Message { + mi := &file_sender_sender_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetRequestByIDRequest.ProtoReflect.Descriptor instead. +func (*GetRequestByIDRequest) Descriptor() ([]byte, []int) { + return file_sender_sender_proto_rawDescGZIP(), []int{2} +} + +func (x *GetRequestByIDRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +type GetRequestByIDResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Request *Request `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetRequestByIDResponse) Reset() { + *x = GetRequestByIDResponse{} + mi := &file_sender_sender_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetRequestByIDResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRequestByIDResponse) ProtoMessage() {} + +func (x *GetRequestByIDResponse) ProtoReflect() protoreflect.Message { + mi := &file_sender_sender_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetRequestByIDResponse.ProtoReflect.Descriptor instead. +func (*GetRequestByIDResponse) Descriptor() ([]byte, []int) { + return file_sender_sender_proto_rawDescGZIP(), []int{3} +} + +func (x *GetRequestByIDResponse) GetRequest() *Request { + if x != nil { + return x.Request + } + return nil +} + +type ListRequestsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListRequestsRequest) Reset() { + *x = ListRequestsRequest{} + mi := &file_sender_sender_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListRequestsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListRequestsRequest) ProtoMessage() {} + +func (x *ListRequestsRequest) ProtoReflect() protoreflect.Message { + mi := &file_sender_sender_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListRequestsRequest.ProtoReflect.Descriptor instead. +func (*ListRequestsRequest) Descriptor() ([]byte, []int) { + return file_sender_sender_proto_rawDescGZIP(), []int{4} +} + +type ListRequestsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Requests []*Request `protobuf:"bytes,1,rep,name=requests,proto3" json:"requests,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListRequestsResponse) Reset() { + *x = ListRequestsResponse{} + mi := &file_sender_sender_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListRequestsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListRequestsResponse) ProtoMessage() {} + +func (x *ListRequestsResponse) ProtoReflect() protoreflect.Message { + mi := &file_sender_sender_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListRequestsResponse.ProtoReflect.Descriptor instead. +func (*ListRequestsResponse) Descriptor() ([]byte, []int) { + return file_sender_sender_proto_rawDescGZIP(), []int{5} +} + +func (x *ListRequestsResponse) GetRequests() []*Request { + if x != nil { + return x.Requests + } + return nil +} + +type CloneFromRequestLogRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + RequestLogId string `protobuf:"bytes,1,opt,name=request_log_id,json=requestLogId,proto3" json:"request_log_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CloneFromRequestLogRequest) Reset() { + *x = CloneFromRequestLogRequest{} + mi := &file_sender_sender_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CloneFromRequestLogRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CloneFromRequestLogRequest) ProtoMessage() {} + +func (x *CloneFromRequestLogRequest) ProtoReflect() protoreflect.Message { + mi := &file_sender_sender_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CloneFromRequestLogRequest.ProtoReflect.Descriptor instead. +func (*CloneFromRequestLogRequest) Descriptor() ([]byte, []int) { + return file_sender_sender_proto_rawDescGZIP(), []int{6} +} + +func (x *CloneFromRequestLogRequest) GetRequestLogId() string { + if x != nil { + return x.RequestLogId + } + return "" +} + +type CloneFromRequestLogResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Request *Request `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CloneFromRequestLogResponse) Reset() { + *x = CloneFromRequestLogResponse{} + mi := &file_sender_sender_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CloneFromRequestLogResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CloneFromRequestLogResponse) ProtoMessage() {} + +func (x *CloneFromRequestLogResponse) ProtoReflect() protoreflect.Message { + mi := &file_sender_sender_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CloneFromRequestLogResponse.ProtoReflect.Descriptor instead. +func (*CloneFromRequestLogResponse) Descriptor() ([]byte, []int) { + return file_sender_sender_proto_rawDescGZIP(), []int{7} +} + +func (x *CloneFromRequestLogResponse) GetRequest() *Request { + if x != nil { + return x.Request + } + return nil +} + +type SendRequestRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SendRequestRequest) Reset() { + *x = SendRequestRequest{} + mi := &file_sender_sender_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SendRequestRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SendRequestRequest) ProtoMessage() {} + +func (x *SendRequestRequest) ProtoReflect() protoreflect.Message { + mi := &file_sender_sender_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SendRequestRequest.ProtoReflect.Descriptor instead. +func (*SendRequestRequest) Descriptor() ([]byte, []int) { + return file_sender_sender_proto_rawDescGZIP(), []int{8} +} + +func (x *SendRequestRequest) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +type SendRequestResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Request *Request `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SendRequestResponse) Reset() { + *x = SendRequestResponse{} + mi := &file_sender_sender_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SendRequestResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SendRequestResponse) ProtoMessage() {} + +func (x *SendRequestResponse) ProtoReflect() protoreflect.Message { + mi := &file_sender_sender_proto_msgTypes[9] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SendRequestResponse.ProtoReflect.Descriptor instead. +func (*SendRequestResponse) Descriptor() ([]byte, []int) { + return file_sender_sender_proto_rawDescGZIP(), []int{9} +} + +func (x *SendRequestResponse) GetRequest() *Request { + if x != nil { + return x.Request + } + return nil +} + +type DeleteRequestsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteRequestsRequest) Reset() { + *x = DeleteRequestsRequest{} + mi := &file_sender_sender_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteRequestsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteRequestsRequest) ProtoMessage() {} + +func (x *DeleteRequestsRequest) ProtoReflect() protoreflect.Message { + mi := &file_sender_sender_proto_msgTypes[10] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteRequestsRequest.ProtoReflect.Descriptor instead. +func (*DeleteRequestsRequest) Descriptor() ([]byte, []int) { + return file_sender_sender_proto_rawDescGZIP(), []int{10} +} + +type DeleteRequestsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteRequestsResponse) Reset() { + *x = DeleteRequestsResponse{} + mi := &file_sender_sender_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteRequestsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteRequestsResponse) ProtoMessage() {} + +func (x *DeleteRequestsResponse) ProtoReflect() protoreflect.Message { + mi := &file_sender_sender_proto_msgTypes[11] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteRequestsResponse.ProtoReflect.Descriptor instead. +func (*DeleteRequestsResponse) Descriptor() ([]byte, []int) { + return file_sender_sender_proto_rawDescGZIP(), []int{11} +} + +type CreateOrUpdateRequestRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Request *Request `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateOrUpdateRequestRequest) Reset() { + *x = CreateOrUpdateRequestRequest{} + mi := &file_sender_sender_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateOrUpdateRequestRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateOrUpdateRequestRequest) ProtoMessage() {} + +func (x *CreateOrUpdateRequestRequest) ProtoReflect() protoreflect.Message { + mi := &file_sender_sender_proto_msgTypes[12] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateOrUpdateRequestRequest.ProtoReflect.Descriptor instead. +func (*CreateOrUpdateRequestRequest) Descriptor() ([]byte, []int) { + return file_sender_sender_proto_rawDescGZIP(), []int{12} +} + +func (x *CreateOrUpdateRequestRequest) GetRequest() *Request { + if x != nil { + return x.Request + } + return nil +} + +type CreateOrUpdateRequestResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Request *Request `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateOrUpdateRequestResponse) Reset() { + *x = CreateOrUpdateRequestResponse{} + mi := &file_sender_sender_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateOrUpdateRequestResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateOrUpdateRequestResponse) ProtoMessage() {} + +func (x *CreateOrUpdateRequestResponse) ProtoReflect() protoreflect.Message { + mi := &file_sender_sender_proto_msgTypes[13] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateOrUpdateRequestResponse.ProtoReflect.Descriptor instead. +func (*CreateOrUpdateRequestResponse) Descriptor() ([]byte, []int) { + return file_sender_sender_proto_rawDescGZIP(), []int{13} +} + +func (x *CreateOrUpdateRequestResponse) GetRequest() *Request { + if x != nil { + return x.Request + } + return nil +} + +type SetRequestsFilterRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Filter *RequestsFilter `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SetRequestsFilterRequest) Reset() { + *x = SetRequestsFilterRequest{} + mi := &file_sender_sender_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SetRequestsFilterRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SetRequestsFilterRequest) ProtoMessage() {} + +func (x *SetRequestsFilterRequest) ProtoReflect() protoreflect.Message { + mi := &file_sender_sender_proto_msgTypes[14] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SetRequestsFilterRequest.ProtoReflect.Descriptor instead. +func (*SetRequestsFilterRequest) Descriptor() ([]byte, []int) { + return file_sender_sender_proto_rawDescGZIP(), []int{14} +} + +func (x *SetRequestsFilterRequest) GetFilter() *RequestsFilter { + if x != nil { + return x.Filter + } + return nil +} + +type SetRequestsFilterResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SetRequestsFilterResponse) Reset() { + *x = SetRequestsFilterResponse{} + mi := &file_sender_sender_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SetRequestsFilterResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SetRequestsFilterResponse) ProtoMessage() {} + +func (x *SetRequestsFilterResponse) ProtoReflect() protoreflect.Message { + mi := &file_sender_sender_proto_msgTypes[15] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SetRequestsFilterResponse.ProtoReflect.Descriptor instead. +func (*SetRequestsFilterResponse) Descriptor() ([]byte, []int) { + return file_sender_sender_proto_rawDescGZIP(), []int{15} +} + +type GetRequestsFilterRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetRequestsFilterRequest) Reset() { + *x = GetRequestsFilterRequest{} + mi := &file_sender_sender_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetRequestsFilterRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRequestsFilterRequest) ProtoMessage() {} + +func (x *GetRequestsFilterRequest) ProtoReflect() protoreflect.Message { + mi := &file_sender_sender_proto_msgTypes[16] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetRequestsFilterRequest.ProtoReflect.Descriptor instead. +func (*GetRequestsFilterRequest) Descriptor() ([]byte, []int) { + return file_sender_sender_proto_rawDescGZIP(), []int{16} +} + +type GetRequestsFilterResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Filter *RequestsFilter `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetRequestsFilterResponse) Reset() { + *x = GetRequestsFilterResponse{} + mi := &file_sender_sender_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetRequestsFilterResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRequestsFilterResponse) ProtoMessage() {} + +func (x *GetRequestsFilterResponse) ProtoReflect() protoreflect.Message { + mi := &file_sender_sender_proto_msgTypes[17] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetRequestsFilterResponse.ProtoReflect.Descriptor instead. +func (*GetRequestsFilterResponse) Descriptor() ([]byte, []int) { + return file_sender_sender_proto_rawDescGZIP(), []int{17} +} + +func (x *GetRequestsFilterResponse) GetFilter() *RequestsFilter { + if x != nil { + return x.Filter + } + return nil +} + +var File_sender_sender_proto protoreflect.FileDescriptor + +var file_sender_sender_proto_rawDesc = []byte{ + 0x0a, 0x13, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x2f, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x1a, 0x0f, 0x68, + 0x74, 0x74, 0x70, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe4, + 0x01, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x12, 0x31, 0x0a, 0x15, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x6c, 0x6f, 0x67, 0x5f, + 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x49, 0x64, 0x12, 0x39, 0x0a, 0x0c, + 0x68, 0x74, 0x74, 0x70, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x2e, + 0x76, 0x31, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x0b, 0x68, 0x74, 0x74, 0x70, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3c, 0x0a, 0x0d, 0x68, 0x74, 0x74, 0x70, 0x5f, + 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, + 0x2e, 0x68, 0x65, 0x74, 0x74, 0x79, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x0c, 0x68, 0x74, 0x74, 0x70, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x55, 0x0a, 0x0e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x73, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x22, 0x0a, 0x0d, 0x6f, 0x6e, 0x6c, 0x79, 0x5f, + 0x69, 0x6e, 0x5f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, + 0x6f, 0x6e, 0x6c, 0x79, 0x49, 0x6e, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, + 0x65, 0x61, 0x72, 0x63, 0x68, 0x5f, 0x65, 0x78, 0x70, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0a, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x45, 0x78, 0x70, 0x72, 0x22, 0x36, 0x0a, 0x15, + 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x79, 0x49, 0x44, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x49, 0x64, 0x22, 0x43, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x42, 0x79, 0x49, 0x44, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, + 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0f, 0x2e, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x15, 0x0a, 0x13, 0x4c, 0x69, 0x73, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x22, 0x43, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2b, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x65, 0x6e, + 0x64, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x08, 0x72, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x73, 0x22, 0x42, 0x0a, 0x1a, 0x43, 0x6c, 0x6f, 0x6e, 0x65, 0x46, 0x72, + 0x6f, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x0e, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x6c, + 0x6f, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x49, 0x64, 0x22, 0x48, 0x0a, 0x1b, 0x43, 0x6c, 0x6f, + 0x6e, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x65, 0x6e, 0x64, + 0x65, 0x72, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x22, 0x33, 0x0a, 0x12, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x22, 0x40, 0x0a, 0x13, 0x53, 0x65, 0x6e, 0x64, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x29, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0f, 0x2e, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x17, 0x0a, 0x15, 0x44, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x22, 0x18, 0x0a, 0x16, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x49, 0x0a, + 0x1c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x29, 0x0a, + 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, + 0x2e, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, + 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x4a, 0x0a, 0x1d, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x4f, 0x72, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x07, 0x72, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x73, 0x65, 0x6e, + 0x64, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x07, 0x72, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x22, 0x4a, 0x0a, 0x18, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x73, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x2e, 0x0a, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x16, 0x2e, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x73, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, + 0x22, 0x1b, 0x0a, 0x19, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x46, + 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1a, 0x0a, + 0x18, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x46, 0x69, 0x6c, 0x74, + 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x4b, 0x0a, 0x19, 0x47, 0x65, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x2e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x06, + 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x32, 0xce, 0x05, 0x0a, 0x0d, 0x53, 0x65, 0x6e, 0x64, 0x65, + 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x51, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x79, 0x49, 0x44, 0x12, 0x1d, 0x2e, 0x73, 0x65, 0x6e, + 0x64, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x79, + 0x49, 0x44, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x73, 0x65, 0x6e, 0x64, + 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x79, 0x49, + 0x44, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4b, 0x0a, 0x0c, 0x4c, + 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x12, 0x1b, 0x2e, 0x73, 0x65, + 0x6e, 0x64, 0x65, 0x72, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x73, 0x65, 0x6e, 0x64, 0x65, + 0x72, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5a, 0x0a, 0x11, 0x53, 0x65, 0x74, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x20, 0x2e, + 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x2e, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x73, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x21, 0x2e, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x2e, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x73, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x12, 0x5a, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x73, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x20, 0x2e, 0x73, 0x65, 0x6e, 0x64, + 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x46, 0x69, + 0x6c, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x73, 0x65, + 0x6e, 0x64, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, + 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x66, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x2e, 0x73, 0x65, 0x6e, 0x64, + 0x65, 0x72, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x25, 0x2e, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, + 0x72, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x60, 0x0a, 0x13, 0x43, 0x6c, 0x6f, 0x6e, + 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x12, + 0x22, 0x2e, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x2e, 0x43, 0x6c, 0x6f, 0x6e, 0x65, 0x46, 0x72, + 0x6f, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x2e, 0x43, 0x6c, 0x6f, + 0x6e, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x48, 0x0a, 0x0b, 0x53, 0x65, + 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x2e, 0x73, 0x65, 0x6e, 0x64, + 0x65, 0x72, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x2e, 0x53, + 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x12, 0x51, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x12, 0x1d, 0x2e, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x2e, + 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x2e, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x28, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x73, 0x74, 0x6f, 0x74, 0x69, 0x6a, 0x6e, 0x2f, 0x68, + 0x65, 0x74, 0x74, 0x79, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x65, 0x6e, 0x64, 0x65, + 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_sender_sender_proto_rawDescOnce sync.Once + file_sender_sender_proto_rawDescData = file_sender_sender_proto_rawDesc +) + +func file_sender_sender_proto_rawDescGZIP() []byte { + file_sender_sender_proto_rawDescOnce.Do(func() { + file_sender_sender_proto_rawDescData = protoimpl.X.CompressGZIP(file_sender_sender_proto_rawDescData) + }) + return file_sender_sender_proto_rawDescData +} + +var file_sender_sender_proto_msgTypes = make([]protoimpl.MessageInfo, 18) +var file_sender_sender_proto_goTypes = []any{ + (*Request)(nil), // 0: sender.Request + (*RequestsFilter)(nil), // 1: sender.RequestsFilter + (*GetRequestByIDRequest)(nil), // 2: sender.GetRequestByIDRequest + (*GetRequestByIDResponse)(nil), // 3: sender.GetRequestByIDResponse + (*ListRequestsRequest)(nil), // 4: sender.ListRequestsRequest + (*ListRequestsResponse)(nil), // 5: sender.ListRequestsResponse + (*CloneFromRequestLogRequest)(nil), // 6: sender.CloneFromRequestLogRequest + (*CloneFromRequestLogResponse)(nil), // 7: sender.CloneFromRequestLogResponse + (*SendRequestRequest)(nil), // 8: sender.SendRequestRequest + (*SendRequestResponse)(nil), // 9: sender.SendRequestResponse + (*DeleteRequestsRequest)(nil), // 10: sender.DeleteRequestsRequest + (*DeleteRequestsResponse)(nil), // 11: sender.DeleteRequestsResponse + (*CreateOrUpdateRequestRequest)(nil), // 12: sender.CreateOrUpdateRequestRequest + (*CreateOrUpdateRequestResponse)(nil), // 13: sender.CreateOrUpdateRequestResponse + (*SetRequestsFilterRequest)(nil), // 14: sender.SetRequestsFilterRequest + (*SetRequestsFilterResponse)(nil), // 15: sender.SetRequestsFilterResponse + (*GetRequestsFilterRequest)(nil), // 16: sender.GetRequestsFilterRequest + (*GetRequestsFilterResponse)(nil), // 17: sender.GetRequestsFilterResponse + (*http.Request)(nil), // 18: hetty.http.v1.Request + (*http.Response)(nil), // 19: hetty.http.v1.Response +} +var file_sender_sender_proto_depIdxs = []int32{ + 18, // 0: sender.Request.http_request:type_name -> hetty.http.v1.Request + 19, // 1: sender.Request.http_response:type_name -> hetty.http.v1.Response + 0, // 2: sender.GetRequestByIDResponse.request:type_name -> sender.Request + 0, // 3: sender.ListRequestsResponse.requests:type_name -> sender.Request + 0, // 4: sender.CloneFromRequestLogResponse.request:type_name -> sender.Request + 0, // 5: sender.SendRequestResponse.request:type_name -> sender.Request + 0, // 6: sender.CreateOrUpdateRequestRequest.request:type_name -> sender.Request + 0, // 7: sender.CreateOrUpdateRequestResponse.request:type_name -> sender.Request + 1, // 8: sender.SetRequestsFilterRequest.filter:type_name -> sender.RequestsFilter + 1, // 9: sender.GetRequestsFilterResponse.filter:type_name -> sender.RequestsFilter + 2, // 10: sender.SenderService.GetRequestByID:input_type -> sender.GetRequestByIDRequest + 4, // 11: sender.SenderService.ListRequests:input_type -> sender.ListRequestsRequest + 14, // 12: sender.SenderService.SetRequestsFilter:input_type -> sender.SetRequestsFilterRequest + 16, // 13: sender.SenderService.GetRequestsFilter:input_type -> sender.GetRequestsFilterRequest + 12, // 14: sender.SenderService.CreateOrUpdateRequest:input_type -> sender.CreateOrUpdateRequestRequest + 6, // 15: sender.SenderService.CloneFromRequestLog:input_type -> sender.CloneFromRequestLogRequest + 8, // 16: sender.SenderService.SendRequest:input_type -> sender.SendRequestRequest + 10, // 17: sender.SenderService.DeleteRequests:input_type -> sender.DeleteRequestsRequest + 3, // 18: sender.SenderService.GetRequestByID:output_type -> sender.GetRequestByIDResponse + 5, // 19: sender.SenderService.ListRequests:output_type -> sender.ListRequestsResponse + 15, // 20: sender.SenderService.SetRequestsFilter:output_type -> sender.SetRequestsFilterResponse + 17, // 21: sender.SenderService.GetRequestsFilter:output_type -> sender.GetRequestsFilterResponse + 13, // 22: sender.SenderService.CreateOrUpdateRequest:output_type -> sender.CreateOrUpdateRequestResponse + 7, // 23: sender.SenderService.CloneFromRequestLog:output_type -> sender.CloneFromRequestLogResponse + 9, // 24: sender.SenderService.SendRequest:output_type -> sender.SendRequestResponse + 11, // 25: sender.SenderService.DeleteRequests:output_type -> sender.DeleteRequestsResponse + 18, // [18:26] is the sub-list for method output_type + 10, // [10:18] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name +} + +func init() { file_sender_sender_proto_init() } +func file_sender_sender_proto_init() { + if File_sender_sender_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_sender_sender_proto_rawDesc, + NumEnums: 0, + NumMessages: 18, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_sender_sender_proto_goTypes, + DependencyIndexes: file_sender_sender_proto_depIdxs, + MessageInfos: file_sender_sender_proto_msgTypes, + }.Build() + File_sender_sender_proto = out.File + file_sender_sender_proto_rawDesc = nil + file_sender_sender_proto_goTypes = nil + file_sender_sender_proto_depIdxs = nil +} diff --git a/pkg/sender/sender_test.go b/pkg/sender/sender_test.go index 5caa404..42f79e5 100644 --- a/pkg/sender/sender_test.go +++ b/pkg/sender/sender_test.go @@ -4,36 +4,24 @@ import ( "context" "errors" "fmt" - "math/rand" - "net/http" + http "net/http" "net/http/httptest" - "net/url" "testing" "time" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" - "github.com/oklog/ulid" + connect "connectrpc.com/connect" "go.etcd.io/bbolt" + "google.golang.org/protobuf/testing/protocmp" "github.com/dstotijn/hetty/pkg/db/bolt" + httppb "github.com/dstotijn/hetty/pkg/http" "github.com/dstotijn/hetty/pkg/proj" "github.com/dstotijn/hetty/pkg/reqlog" "github.com/dstotijn/hetty/pkg/sender" + "github.com/dstotijn/hetty/pkg/testutil" + "github.com/google/go-cmp/cmp" ) -//nolint:gosec -var ulidEntropy = rand.New(rand.NewSource(time.Now().UnixNano())) - -var exampleURL = func() *url.URL { - u, err := url.Parse("https://example.com/foobar") - if err != nil { - panic(err) - } - - return u -}() - func TestStoreRequest(t *testing.T) { t.Parallel() @@ -42,10 +30,16 @@ func TestStoreRequest(t *testing.T) { svc := sender.NewService(sender.Config{}) - _, err := svc.CreateOrUpdateRequest(context.Background(), sender.Request{ - URL: exampleURL, - Method: http.MethodPost, - Body: []byte("foobar"), + _, err := svc.CreateOrUpdateRequest(context.Background(), &connect.Request[sender.CreateOrUpdateRequestRequest]{ + Msg: &sender.CreateOrUpdateRequestRequest{ + Request: &sender.Request{ + HttpRequest: &httppb.Request{ + Url: "https://example.com/foobar", + Method: httppb.Method_METHOD_POST, + Body: []byte("foobar"), + }, + }, + }, }) if !errors.Is(err, sender.ErrProjectIDMustBeSet) { t.Fatalf("expected `sender.ErrProjectIDMustBeSet`, got: %v", err) @@ -72,75 +66,69 @@ func TestStoreRequest(t *testing.T) { Repository: db, }) - projectID := ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) - err = db.UpsertProject(context.Background(), proj.Project{ - ID: projectID, - Name: "foobar", - Settings: proj.Settings{}, + projectID := "foobar-project-id" + err = db.UpsertProject(context.Background(), &proj.Project{ + Id: projectID, + Name: "foobar", }) if err != nil { t.Fatalf("unexpected error upserting project: %v", err) } - svc.SetActiveProjectID(projectID) svc.SetActiveProjectID(projectID) - exp := sender.Request{ - ProjectID: projectID, - URL: exampleURL, - Method: http.MethodPost, - Proto: "HTTP/1.1", - Header: http.Header{ - "X-Foo": []string{"bar"}, + exp := &sender.Request{ + ProjectId: projectID, + HttpRequest: &httppb.Request{ + Method: httppb.Method_METHOD_POST, + Protocol: httppb.Protocol_PROTOCOL_HTTP20, + Url: "https://example.com/foobar", + Headers: []*httppb.Header{ + {Key: "X-Foo", Value: "bar"}, + }, + Body: []byte("foobar"), }, - Body: []byte("foobar"), } - got, err := svc.CreateOrUpdateRequest(context.Background(), sender.Request{ - URL: exampleURL, - Method: http.MethodPost, - Proto: "HTTP/1.1", - Header: http.Header{ - "X-Foo": []string{"bar"}, + createRes, err := svc.CreateOrUpdateRequest(context.Background(), &connect.Request[sender.CreateOrUpdateRequestRequest]{ + Msg: &sender.CreateOrUpdateRequestRequest{ + Request: exp, }, - Body: []byte("foobar"), }) if err != nil { t.Fatalf("unexpected error storing request: %v", err) } - if got.ID.Compare(ulid.ULID{}) == 0 { + if createRes.Msg.Request.Id == "" { t.Fatal("expected request ID to be non-empty value") } - diff := cmp.Diff(exp, got, cmpopts.IgnoreFields(sender.Request{}, "ID")) - if diff != "" { - t.Fatalf("request not equal (-exp, +got):\n%v", diff) - } + testutil.ProtoDiff(t, "request not equal", exp, createRes.Msg.Request, "id") - got, err = db.FindSenderRequestByID(context.Background(), projectID, got.ID) + got, err := db.FindSenderRequestByID(context.Background(), projectID, createRes.Msg.Request.Id) if err != nil { t.Fatalf("failed to find request by ID: %v", err) } - diff = cmp.Diff(exp, got, cmpopts.IgnoreFields(sender.Request{}, "ID")) - if diff != "" { - t.Fatalf("request not equal (-exp, +got):\n%v", diff) - } + testutil.ProtoDiff(t, "request not equal", exp, got, "id") }) } func TestCloneFromRequestLog(t *testing.T) { t.Parallel() - reqLogID := ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) + reqLogID := "foobar-req-log-id" t.Run("without active project", func(t *testing.T) { t.Parallel() svc := sender.NewService(sender.Config{}) - _, err := svc.CloneFromRequestLog(context.Background(), reqLogID) + _, err := svc.CloneFromRequestLog(context.Background(), &connect.Request[sender.CloneFromRequestLogRequest]{ + Msg: &sender.CloneFromRequestLogRequest{ + RequestLogId: reqLogID, + }, + }) if !errors.Is(err, sender.ErrProjectIDMustBeSet) { t.Fatalf("expected `sender.ErrProjectIDMustBeSet`, got: %v", err) } @@ -162,24 +150,32 @@ func TestCloneFromRequestLog(t *testing.T) { } defer db.Close() - projectID := ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) - err = db.UpsertProject(context.Background(), proj.Project{ - ID: projectID, + projectID := "foobar-project-id" + err = db.UpsertProject(context.Background(), &proj.Project{ + Id: projectID, + Name: "foobar", }) if err != nil { t.Fatalf("unexpected error upserting project: %v", err) } - reqLog := reqlog.RequestLog{ - ID: reqLogID, - ProjectID: projectID, - URL: exampleURL, - Method: http.MethodPost, - Proto: "HTTP/1.1", - Header: http.Header{ - "X-Foo": []string{"bar"}, + reqLog := &reqlog.HttpRequestLog{ + Id: reqLogID, + ProjectId: projectID, + Request: &httppb.Request{ + Url: "https://example.com/foobar", + Method: httppb.Method_METHOD_POST, + Body: []byte("foobar"), + Headers: []*httppb.Header{ + {Key: "X-Foo", Value: "bar"}, + }, + }, + Response: &httppb.Response{ + Protocol: httppb.Protocol_PROTOCOL_HTTP20, + StatusCode: 200, + Status: "200 OK", + Body: []byte("foobar"), }, - Body: []byte("foobar"), } if err := db.StoreRequestLog(context.Background(), reqLog); err != nil { @@ -196,27 +192,29 @@ func TestCloneFromRequestLog(t *testing.T) { svc.SetActiveProjectID(projectID) - exp := sender.Request{ - SourceRequestLogID: reqLogID, - ProjectID: projectID, - URL: exampleURL, - Method: http.MethodPost, - Proto: sender.HTTPProto20, - Header: http.Header{ - "X-Foo": []string{"bar"}, + exp := &sender.Request{ + SourceRequestLogId: reqLogID, + ProjectId: projectID, + HttpRequest: &httppb.Request{ + Url: "https://example.com/foobar", + Method: httppb.Method_METHOD_POST, + Body: []byte("foobar"), + Headers: []*httppb.Header{ + {Key: "X-Foo", Value: "bar"}, + }, }, - Body: []byte("foobar"), } - got, err := svc.CloneFromRequestLog(context.Background(), reqLogID) + got, err := svc.CloneFromRequestLog(context.Background(), &connect.Request[sender.CloneFromRequestLogRequest]{ + Msg: &sender.CloneFromRequestLogRequest{ + RequestLogId: reqLogID, + }, + }) if err != nil { t.Fatalf("unexpected error cloning from request log: %v", err) } - diff := cmp.Diff(exp, got, cmpopts.IgnoreFields(sender.Request{}, "ID")) - if diff != "" { - t.Fatalf("request not equal (-exp, +got):\n%v", diff) - } + testutil.ProtoDiff(t, "request not equal", exp, got.Msg.Request, "id") }) } @@ -245,28 +243,27 @@ func TestSendRequest(t *testing.T) { })) defer ts.Close() - tsURL, _ := url.Parse(ts.URL) - - projectID := ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) - err = db.UpsertProject(context.Background(), proj.Project{ - ID: projectID, - Settings: proj.Settings{}, + projectID := "foobar-project-id" + err = db.UpsertProject(context.Background(), &proj.Project{ + Id: projectID, + Name: "foobar", }) if err != nil { t.Fatalf("unexpected error upserting project: %v", err) } - reqID := ulid.MustNew(ulid.Timestamp(time.Now()), ulidEntropy) - req := sender.Request{ - ID: reqID, - ProjectID: projectID, - URL: tsURL, - Method: http.MethodPost, - Proto: "HTTP/1.1", - Header: http.Header{ - "X-Foo": []string{"bar"}, + reqID := "foobar-req-id" + req := &sender.Request{ + Id: reqID, + ProjectId: projectID, + HttpRequest: &httppb.Request{ + Url: ts.URL, + Method: httppb.Method_METHOD_POST, + Body: []byte("foobar"), + Headers: []*httppb.Header{ + {Key: "X-Foo", Value: "bar"}, + }, }, - Body: []byte("foobar"), } if err := db.StoreSenderRequest(context.Background(), req); err != nil { @@ -281,26 +278,38 @@ func TestSendRequest(t *testing.T) { }) svc.SetActiveProjectID(projectID) - exp := &reqlog.ResponseLog{ - Proto: "HTTP/1.1", - StatusCode: http.StatusOK, + exp := &httppb.Response{ + Protocol: httppb.Protocol_PROTOCOL_HTTP11, + StatusCode: 200, Status: "200 OK", - Header: http.Header{ - "Content-Length": []string{"3"}, - "Content-Type": []string{"text/plain; charset=utf-8"}, - "Date": []string{date}, - "Foobar": []string{"baz"}, + Headers: []*httppb.Header{ + {Key: "Date", Value: date}, + {Key: "Foobar", Value: "baz"}, + {Key: "Content-Length", Value: "3"}, + {Key: "Content-Type", Value: "text/plain; charset=utf-8"}, }, Body: []byte("baz"), } - got, err := svc.SendRequest(context.Background(), reqID) + got, err := svc.SendRequest(context.Background(), &connect.Request[sender.SendRequestRequest]{ + Msg: &sender.SendRequestRequest{ + RequestId: reqID, + }, + }) if err != nil { t.Fatalf("unexpected error sending request: %v", err) } - diff := cmp.Diff(exp, got.Response, cmpopts.IgnoreFields(sender.Request{}, "ID")) - if diff != "" { - t.Fatalf("request not equal (-exp, +got):\n%v", diff) + opts := []cmp.Option{ + protocmp.Transform(), + protocmp.SortRepeated(func(a, b *httppb.Header) bool { + if a.Key != b.Key { + return a.Key < b.Key + } + return a.Value < b.Value + }), + } + if diff := cmp.Diff(exp, got.Msg.Request.HttpResponse, opts...); diff != "" { + t.Fatalf("response not equal (-exp, +got):\n%v", diff) } } diff --git a/pkg/sender/transport.go b/pkg/sender/transport.go index e26e38a..254fae7 100644 --- a/pkg/sender/transport.go +++ b/pkg/sender/transport.go @@ -45,7 +45,3 @@ func (t *HTTPTransport) RoundTrip(req *http.Request) (*http.Response, error) { return http.DefaultTransport.RoundTrip(req) } - -func isValidProto(proto string) bool { - return proto == HTTPProto10 || proto == HTTPProto11 || proto == HTTPProto20 -} diff --git a/pkg/testutil/testutil.go b/pkg/testutil/testutil.go new file mode 100644 index 0000000..d76ef61 --- /dev/null +++ b/pkg/testutil/testutil.go @@ -0,0 +1,54 @@ +package testutil + +import ( + "testing" + + "github.com/dstotijn/hetty/pkg/log" + "github.com/google/go-cmp/cmp" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/testing/protocmp" +) + +func ProtoDiff[M proto.Message](t *testing.T, msg string, exp, got M, ignoreFields ...protoreflect.Name) { + t.Helper() + + opts := []cmp.Option{ + protocmp.Transform(), + protocmp.IgnoreFields(exp, ignoreFields...), + } + + if diff := cmp.Diff(exp, got, opts...); diff != "" { + t.Fatalf("%v (-exp, +got):\n%v", msg, diff) + } +} + +func ProtoSlicesDiff[M proto.Message](t *testing.T, msg string, exp, got []M, ignoreFields ...protoreflect.Name) { + t.Helper() + + opts := []cmp.Option{ + protocmp.Transform(), + } + if len(exp) > 0 { + opts = append(opts, protocmp.IgnoreFields(exp[0], ignoreFields...)) + } + + if diff := cmp.Diff(exp, got, opts...); diff != "" { + t.Fatalf("%v (-exp, +got):\n%v", msg, diff) + } +} + +type testLogger struct { + log.NopLogger + t *testing.T +} + +func (l *testLogger) Errorw(msg string, v ...interface{}) { + l.t.Helper() + l.t.Fatalf(msg+": %v", v...) +} + +func NewLogger(t *testing.T) log.Logger { + t.Helper() + return &testLogger{t: t} +} diff --git a/proto/http/http.proto b/proto/http/http.proto new file mode 100644 index 0000000..ed88e74 --- /dev/null +++ b/proto/http/http.proto @@ -0,0 +1,47 @@ +syntax = "proto3"; + +package hetty.http.v1; + +option go_package = "github.com/dstotijn/hetty/pkg/http"; + +enum Method { + METHOD_UNSPECIFIED = 0; + METHOD_GET = 1; + METHOD_HEAD = 2; + METHOD_POST = 3; + METHOD_PUT = 4; + METHOD_DELETE = 5; + METHOD_CONNECT = 6; + METHOD_OPTIONS = 7; + METHOD_TRACE = 8; + METHOD_PATCH = 9; +} + +enum Protocol { + PROTOCOL_UNSPECIFIED = 0; + PROTOCOL_HTTP10 = 1; + PROTOCOL_HTTP11 = 2; + PROTOCOL_HTTP20 = 3; +} + +message Request { + Method method = 1; + Protocol protocol = 2; + string url = 3; + repeated Header headers = 4; + bytes body = 5; + Response response = 6; +} + +message Response { + Protocol protocol = 1; + string status = 2; + int32 status_code = 3; + repeated Header headers = 5; + bytes body = 6; +} + +message Header { + string key = 1; + string value = 2; +} diff --git a/proto/proj/proj.proto b/proto/proj/proj.proto new file mode 100644 index 0000000..0a7f0c4 --- /dev/null +++ b/proto/proj/proj.proto @@ -0,0 +1,104 @@ +syntax = "proto3"; + +package hetty.proj.v1; + +import "reqlog/reqlog.proto"; +import "scope/scope.proto"; + +option go_package = "github.com/dstotijn/hetty/pkg/proj"; + +message Project { + string id = 1; + string name = 2; + bool is_active = 3; + + // Request log settings + bool req_log_bypass_out_of_scope = 4; + + // Request logs filter + hetty.reqlog.v1.RequestLogsFilter req_log_filter = 5; + + // Intercept settings + bool intercept_requests = 6; + bool intercept_responses = 7; + string intercept_request_filter_expr = 8; + string intercept_response_filter_expr = 9; + + // Sender settings + bool sender_only_find_in_scope = 10; + string sender_search_expr = 11; + + // Scope settings + repeated hetty.scope.v1.ScopeRule scope_rules = 12; +} + +message CreateProjectRequest { + string name = 1; +} + +message CreateProjectResponse { + Project project = 1; +} + +message OpenProjectRequest { + string project_id = 1; +} + +message OpenProjectResponse { + Project project = 1; +} + +message CloseProjectRequest {} + +message CloseProjectResponse {} + +message DeleteProjectRequest { + string project_id = 1; +} + +message DeleteProjectResponse {} + +message GetActiveProjectRequest {} + +message GetActiveProjectResponse { + Project project = 1; +} + +message ListProjectsRequest {} + +message ListProjectsResponse { + repeated Project projects = 1; +} + +message UpdateInterceptSettingsRequest { + bool requests_enabled = 1; + bool responses_enabled = 2; + string request_filter_expr = 3; + string response_filter_expr = 4; +} + +message UpdateInterceptSettingsResponse {} + +message SetScopeRulesRequest { + repeated hetty.scope.v1.ScopeRule rules = 1; +} + +message SetScopeRulesResponse {} + +message SetRequestLogsFilterRequest { + hetty.reqlog.v1.RequestLogsFilter filter = 1; +} + +message SetRequestLogsFilterResponse {} + +service ProjectService { + rpc CreateProject(CreateProjectRequest) returns (CreateProjectResponse) {} + rpc OpenProject(OpenProjectRequest) returns (OpenProjectResponse) {} + rpc CloseProject(CloseProjectRequest) returns (CloseProjectResponse) {} + rpc DeleteProject(DeleteProjectRequest) returns (DeleteProjectResponse) {} + rpc GetActiveProject(GetActiveProjectRequest) returns (GetActiveProjectResponse) {} + rpc ListProjects(ListProjectsRequest) returns (ListProjectsResponse) {} + rpc UpdateInterceptSettings(UpdateInterceptSettingsRequest) returns (UpdateInterceptSettingsResponse) {} + rpc SetScopeRules(SetScopeRulesRequest) returns (SetScopeRulesResponse) {} + rpc SetRequestLogsFilter(SetRequestLogsFilterRequest) returns (SetRequestLogsFilterResponse) {} +} diff --git a/proto/reqlog/reqlog.proto b/proto/reqlog/reqlog.proto new file mode 100644 index 0000000..020a807 --- /dev/null +++ b/proto/reqlog/reqlog.proto @@ -0,0 +1,44 @@ +syntax = "proto3"; + +package hetty.reqlog.v1; + +import "http/http.proto"; + +option go_package = "github.com/dstotijn/hetty/pkg/reqlog"; + +message HttpRequestLog { + string id = 1; + string project_id = 2; + string remote_ip = 3; + hetty.http.v1.Request request = 4; + hetty.http.v1.Response response = 5; +} + +message GetHttpRequestLogRequest { + string id = 1; +} + +message GetHttpRequestLogResponse { + HttpRequestLog http_request_log = 1; +} + +message ListHttpRequestLogsRequest {} + +message ListHttpRequestLogsResponse { + repeated HttpRequestLog http_request_logs = 1; +} + +message RequestLogsFilter { + bool only_in_scope = 1; + string search_expr = 2; +} + +message ClearHttpRequestLogsRequest {} + +message ClearHttpRequestLogsResponse {} + +service HttpRequestLogService { + rpc GetHttpRequestLog(GetHttpRequestLogRequest) returns (GetHttpRequestLogResponse) {} + rpc ListHttpRequestLogs(ListHttpRequestLogsRequest) returns (ListHttpRequestLogsResponse) {} + rpc ClearHttpRequestLogs(ClearHttpRequestLogsRequest) returns (ClearHttpRequestLogsResponse) {} +} diff --git a/proto/scope/scope.proto b/proto/scope/scope.proto new file mode 100644 index 0000000..850b280 --- /dev/null +++ b/proto/scope/scope.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +package hetty.scope.v1; + +option go_package = "github.com/dstotijn/hetty/pkg/scope"; + +message ScopeRule { + string url_regexp = 1; + string header_key_regexp = 2; + string header_value_regexp = 3; + string body_regexp = 4; +} diff --git a/proto/sender/sender.proto b/proto/sender/sender.proto new file mode 100644 index 0000000..2dfbea0 --- /dev/null +++ b/proto/sender/sender.proto @@ -0,0 +1,85 @@ +syntax = "proto3"; + +package sender; + +import "http/http.proto"; + +option go_package = "github.com/dstotijn/hetty/proto/sender"; + +message Request { + string id = 1; + string project_id = 2; + string source_request_log_id = 3; + hetty.http.v1.Request http_request = 4; + hetty.http.v1.Response http_response = 10; +} + +message RequestsFilter { + bool only_in_scope = 1; + string search_expr = 2; +} + +message GetRequestByIDRequest { + string request_id = 1; +} + +message GetRequestByIDResponse { + Request request = 1; +} + +message ListRequestsRequest {} + +message ListRequestsResponse { + repeated Request requests = 1; +} + +message CloneFromRequestLogRequest { + string request_log_id = 1; +} + +message CloneFromRequestLogResponse { + Request request = 1; +} + +message SendRequestRequest { + string request_id = 1; +} + +message SendRequestResponse { + Request request = 1; +} + +message DeleteRequestsRequest {} + +message DeleteRequestsResponse {} + +message CreateOrUpdateRequestRequest { + Request request = 1; +} + +message CreateOrUpdateRequestResponse { + Request request = 1; +} + +message SetRequestsFilterRequest { + RequestsFilter filter = 1; +} + +message SetRequestsFilterResponse {} + +message GetRequestsFilterRequest {} + +message GetRequestsFilterResponse { + RequestsFilter filter = 1; +} + +service SenderService { + rpc GetRequestByID(GetRequestByIDRequest) returns (GetRequestByIDResponse) {} + rpc ListRequests(ListRequestsRequest) returns (ListRequestsResponse) {} + rpc SetRequestsFilter(SetRequestsFilterRequest) returns (SetRequestsFilterResponse) {} + rpc GetRequestsFilter(GetRequestsFilterRequest) returns (GetRequestsFilterResponse) {} + rpc CreateOrUpdateRequest(CreateOrUpdateRequestRequest) returns (CreateOrUpdateRequestResponse) {} + rpc CloneFromRequestLog(CloneFromRequestLogRequest) returns (CloneFromRequestLogResponse) {} + rpc SendRequest(SendRequestRequest) returns (SendRequestResponse) {} + rpc DeleteRequests(DeleteRequestsRequest) returns (DeleteRequestsResponse) {} +} diff --git a/tools.go b/tools.go deleted file mode 100644 index fcdeac4..0000000 --- a/tools.go +++ /dev/null @@ -1,8 +0,0 @@ -//go:build tools -// +build tools - -package tools - -import ( - _ "github.com/99designs/gqlgen" -)