Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions go/net/http/go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
module github.com/google/sqlcommenter/go/net/http

go 1.19

require github.com/google/sqlcommenter/go/core v0.0.2-beta

require (
go.opentelemetry.io/otel v1.11.1 // indirect
go.opentelemetry.io/otel/trace v1.11.1 // indirect
)
19 changes: 0 additions & 19 deletions go/net/http/go.sum
Original file line number Diff line number Diff line change
@@ -1,19 +0,0 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/sqlcommenter/go/core v0.0.1-beta h1:IVszEHanWVeS7UcmP8C3SHa57CmfeqMBj0QUcJ8VZ9Q=
github.com/google/sqlcommenter/go/core v0.0.1-beta/go.mod h1:CZfcqmbIxngExnZ7Se6AsKNVubZhKyi54aeDJZiqTMQ=
github.com/google/sqlcommenter/go/core v0.0.2-beta h1:VnX58Jvf1mkI5KveBddZhCm4YtzG9IQErCNdmfXBU1I=
github.com/google/sqlcommenter/go/core v0.0.2-beta/go.mod h1:CZfcqmbIxngExnZ7Se6AsKNVubZhKyi54aeDJZiqTMQ=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
go.opentelemetry.io/otel v1.10.0 h1:Y7DTJMR6zs1xkS/upamJYk0SxxN4C9AqRd77jmZnyY4=
go.opentelemetry.io/otel v1.10.0/go.mod h1:NbvWjCthWHKBEUMpf0/v8ZRZlni86PpGFEMA9pnQSnQ=
go.opentelemetry.io/otel v1.11.1 h1:4WLLAmcfkmDk2ukNXJyq3/kiz/3UzCaYq6PskJsaou4=
go.opentelemetry.io/otel v1.11.1/go.mod h1:1nNhXBbWSD0nsL38H6btgnFN2k4i0sNLHNNMZMSbUGE=
go.opentelemetry.io/otel/trace v1.10.0 h1:npQMbR8o7mum8uF95yFbOEJffhs1sbCOfDh8zAJiH5E=
go.opentelemetry.io/otel/trace v1.10.0/go.mod h1:Sij3YYczqAdz+EhmGhE6TpTxUO5/F/AzrK+kxfGqySM=
go.opentelemetry.io/otel/trace v1.11.1 h1:ofxdnzsNrGBYXbP7t7zpUK281+go5rF7dvdIZXF8gdQ=
go.opentelemetry.io/otel/trace v1.11.1/go.mod h1:f/Q9G7vzk5u91PhbmKbg1Qn0rzH1LJ4vbPHFGkTPtOk=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
29 changes: 12 additions & 17 deletions go/net/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,24 @@

package http

import (
"net/http"

"github.com/google/sqlcommenter/go/core"
)

type HTTPRequestExtractor struct {
r *http.Request
next any
type HTTPRequestTags struct {
framework string
route string
action string
}

func NewHTTPRequestExtractor(r *http.Request, next any) *HTTPRequestExtractor {
return &HTTPRequestExtractor{r, next}
func NewHTTPRequestTags(framework, route, action string) *HTTPRequestTags {
return &HTTPRequestTags{framework, route, action}
}

func (h *HTTPRequestExtractor) Route() string {
return h.r.URL.Path
func (h *HTTPRequestTags) Route() string {
return h.route
}

func (h *HTTPRequestExtractor) Action() string {
return core.GetFunctionName(h.next)
func (h *HTTPRequestTags) Action() string {
return h.action
}

func (h *HTTPRequestExtractor) Framework() string {
return "net/http"
func (h *HTTPRequestTags) Framework() string {
return h.framework
}
19 changes: 19 additions & 0 deletions go/net/http/http_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package http

import "testing"

func TestNewHTTPRequestTags(t *testing.T) {
rt := NewHTTPRequestTags("f", "r", "a")

if rt.framework != "f" {
t.Errorf("rt.framework - got: %s, want: %s", rt.framework, "f")
}

if rt.route != "r" {
t.Errorf("rt.route - got: %s, want: %s", rt.route, "r")
}

if rt.action != "a" {
t.Errorf("rt.action - got: %s, want: %s", rt.action, "r")
}
}