File tree 4 files changed +31
-43
lines changed
4 files changed +31
-43
lines changed Original file line number Diff line number Diff line change 1
1
module github.com/google/sqlcommenter/go/net/http
2
2
3
3
go 1.19
4
-
5
- require github.com/google/sqlcommenter/go/core v0.0.2-beta
6
-
7
- require (
8
- go.opentelemetry.io/otel v1.11.1 // indirect
9
- go.opentelemetry.io/otel/trace v1.11.1 // indirect
10
- )
Original file line number Diff line number Diff line change 1
- github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8 =
2
- github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0 =
3
- github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag =
4
- github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg =
5
- github.com/google/sqlcommenter/go/core v0.0.1-beta h1:IVszEHanWVeS7UcmP8C3SHa57CmfeqMBj0QUcJ8VZ9Q =
6
- github.com/google/sqlcommenter/go/core v0.0.1-beta /go.mod h1:CZfcqmbIxngExnZ7Se6AsKNVubZhKyi54aeDJZiqTMQ =
7
- github.com/google/sqlcommenter/go/core v0.0.2-beta h1:VnX58Jvf1mkI5KveBddZhCm4YtzG9IQErCNdmfXBU1I =
8
- github.com/google/sqlcommenter/go/core v0.0.2-beta /go.mod h1:CZfcqmbIxngExnZ7Se6AsKNVubZhKyi54aeDJZiqTMQ =
9
- github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM =
10
- github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY =
11
- go.opentelemetry.io/otel v1.10.0 h1:Y7DTJMR6zs1xkS/upamJYk0SxxN4C9AqRd77jmZnyY4 =
12
- go.opentelemetry.io/otel v1.10.0 /go.mod h1:NbvWjCthWHKBEUMpf0/v8ZRZlni86PpGFEMA9pnQSnQ =
13
- go.opentelemetry.io/otel v1.11.1 h1:4WLLAmcfkmDk2ukNXJyq3/kiz/3UzCaYq6PskJsaou4 =
14
- go.opentelemetry.io/otel v1.11.1 /go.mod h1:1nNhXBbWSD0nsL38H6btgnFN2k4i0sNLHNNMZMSbUGE =
15
- go.opentelemetry.io/otel/trace v1.10.0 h1:npQMbR8o7mum8uF95yFbOEJffhs1sbCOfDh8zAJiH5E =
16
- go.opentelemetry.io/otel/trace v1.10.0 /go.mod h1:Sij3YYczqAdz+EhmGhE6TpTxUO5/F/AzrK+kxfGqySM =
17
- go.opentelemetry.io/otel/trace v1.11.1 h1:ofxdnzsNrGBYXbP7t7zpUK281+go5rF7dvdIZXF8gdQ =
18
- go.opentelemetry.io/otel/trace v1.11.1 /go.mod h1:f/Q9G7vzk5u91PhbmKbg1Qn0rzH1LJ4vbPHFGkTPtOk =
19
- gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo =
Original file line number Diff line number Diff line change 14
14
15
15
package http
16
16
17
- import (
18
- "net/http"
19
-
20
- "github.com/google/sqlcommenter/go/core"
21
- )
22
-
23
- type HTTPRequestExtractor struct {
24
- r * http.Request
25
- next any
17
+ type HTTPRequestTags struct {
18
+ framework string
19
+ route string
20
+ action string
26
21
}
27
22
28
- func NewHTTPRequestExtractor ( r * http. Request , next any ) * HTTPRequestExtractor {
29
- return & HTTPRequestExtractor { r , next }
23
+ func NewHTTPRequestTags ( framework , route , action string ) * HTTPRequestTags {
24
+ return & HTTPRequestTags { framework , route , action }
30
25
}
31
26
32
- func (h * HTTPRequestExtractor ) Route () string {
33
- return h .r . URL . Path
27
+ func (h * HTTPRequestTags ) Route () string {
28
+ return h .route
34
29
}
35
30
36
- func (h * HTTPRequestExtractor ) Action () string {
37
- return core . GetFunctionName ( h . next )
31
+ func (h * HTTPRequestTags ) Action () string {
32
+ return h . action
38
33
}
39
34
40
- func (h * HTTPRequestExtractor ) Framework () string {
41
- return "net/http"
35
+ func (h * HTTPRequestTags ) Framework () string {
36
+ return h . framework
42
37
}
Original file line number Diff line number Diff line change
1
+ package http
2
+
3
+ import "testing"
4
+
5
+ func TestNewHTTPRequestTags (t * testing.T ) {
6
+ rt := NewHTTPRequestTags ("f" , "r" , "a" )
7
+
8
+ if rt .framework != "f" {
9
+ t .Errorf ("rt.framework - got: %s, want: %s" , rt .framework , "f" )
10
+ }
11
+
12
+ if rt .route != "r" {
13
+ t .Errorf ("rt.route - got: %s, want: %s" , rt .route , "r" )
14
+ }
15
+
16
+ if rt .action != "a" {
17
+ t .Errorf ("rt.action - got: %s, want: %s" , rt .action , "r" )
18
+ }
19
+ }
You can’t perform that action at this time.
0 commit comments