summaryrefslogtreecommitdiff
path: root/http.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-20 13:21:03 -0500
committerJeff Carr <[email protected]>2025-10-20 13:21:03 -0500
commit69b5038c58e6a8487f22aeaf28eddec5c785c283 (patch)
tree72b9910c32a803d8c7f3bffc0f5d7175516d39b0 /http.go
parent2ecc340541f88d4c1cbe437efe79a6fcfdbf5499 (diff)
probably better. notsure
Diffstat (limited to 'http.go')
-rw-r--r--http.go107
1 files changed, 6 insertions, 101 deletions
diff --git a/http.go b/http.go
index 5ebe55f..82aed13 100644
--- a/http.go
+++ b/http.go
@@ -2,23 +2,11 @@
package forgepb
-import (
- "bytes"
- "io/ioutil"
- "net"
- "net/http"
- "net/url"
- "os/user"
- "strings"
-
- "go.wit.com/lib/protobuf/gitpb"
- "go.wit.com/log"
-)
-
+/*
func (f *Forge) HttpPost(base string, route string, data []byte) ([]byte, error) {
// Fix using url.JoinPath (Best Practice)
- baseURL, _ := url.Parse(f.Config.ForgeURL) // "http://forge.grid.wit.com:2520")
- finalURL := baseURL.JoinPath(route) // Correctly produces ...:2520/patches
+ baseURL, _ := url.Parse(config.Get("ForgeURL")) // "http://forge.grid.wit.com:2520")
+ finalURL := baseURL.JoinPath(route) // Correctly produces ...:2520/patches
var err error
var req *http.Request
@@ -28,9 +16,8 @@ func (f *Forge) HttpPost(base string, route string, data []byte) ([]byte, error)
return nil, err
}
- usr, _ := user.Current()
- req.Header.Set("author", usr.Username)
- req.Header.Set("hostname", f.hostname)
+ req.Header.Set("author", config.Get("author"))
+ req.Header.Set("hostname", config.Get("hostname"))
return rawHttpPost(req)
}
@@ -51,89 +38,6 @@ func rawHttpPost(req *http.Request) ([]byte, error) {
return body, nil
}
-func (f *Forge) LookupPBorig(check *gitpb.Repos) (*gitpb.Repos, error) {
- url := f.Config.ForgeURL + "lookup"
-
- for repo := range check.IterByFullPath() {
- if repo.Namespace == "" {
- repo.Namespace = repo.GoInfo.GoPath
- }
- }
-
- return check.SubmitReposPB(url)
-}
-
-/*
-func (f *Forge) LookupPB(check *gitpb.Repos) (*gitpb.Repos, error) {
- url := f.forgeURL + "lookup"
-
- queryPB := gitpb.NewRepos()
-
- for repo := range check.IterByFullPath() {
- ns := repo.Namespace
- if ns == "" {
- ns = repo.GoInfo.GoPath
- }
-
- newr := new(gitpb.Repo)
- newr.Namespace = ns
-
- queryPB.AppendByNamespace(newr)
- }
-
- return queryPB.SubmitReposPB(url)
-}
-
-func (f *Forge) UpdatePB(check *gitpb.Repos) (*gitpb.Repos, error) {
- url := f.forgeURL + "update"
-
- queryPB := gitpb.NewRepos()
-
- for repo := range check.IterByFullPath() {
- ns := repo.Namespace
- if ns == "" {
- ns = repo.GoInfo.GoPath
- }
-
- newr := new(gitpb.Repo)
- newr.Namespace = ns
-
- queryPB.AppendByNamespace(newr)
- }
-
- return queryPB.SubmitReposPB(url)
-}
-*/
-
-/*
-// HTTPRequestToProto converts an *http.Request to our custom HttpRequest protobuf message.
-func (pb *Patches) AddHttpToPB(r *http.Request) error {
- if pb == nil {
- return log.Errorf("AddHttpToPB() pb was nil")
- }
- // Convert the header map. http.Header is a map[string][]string.
- // We'll just take the first value for each header for simplicity.
- headers := make(map[string]string)
- for name, values := range r.Header {
- if len(values) > 0 {
- headers[name] = strings.Join(values, "\n")
- }
- }
-
- pb.HttpRequest = &httppb.HttpRequest{
- Method: r.Method,
- URL: r.URL.String(),
- Proto: r.Proto,
- Headers: headers,
- IP: getClientIP(r),
- Host: r.Host,
- Hostname: r.Header.Get("hostname"),
- }
- // pb.HttpRequest.Route = cleanURL(r.URL.Path)
- return nil
-}
-*/
-
func getIpSimple(r *http.Request) string {
host, _, err := net.SplitHostPort(r.RemoteAddr)
if err != nil {
@@ -159,3 +63,4 @@ func getClientIP(r *http.Request) string {
}
return host
}
+*/