[go-nuts] How to register a new HTTP handler to an HTTP proxy

2023-09-01 Thread Van Fury
Hi, I have a working proxy and would like to add register additional handler that will receive HTTP request from an HTTP client and return response. How can register this new handler(FooHandler) to the proxy? func main() { logger.Log.Infof("Server Name: [%s]", description) done :=

Re: [go-nuts] How to encode/decode string to binary in golang

2023-03-16 Thread Van Fury
ppreciated!! On Wed, Mar 15, 2023 at 6:39 PM Jesper Louis Andersen < jesper.louis.ander...@gmail.com> wrote: > On Tue, Mar 14, 2023 at 10:25 AM Van Fury wrote: > >> Am developing a server (diameter) which will response with an AVP >> SIP-Authenticate. >> In the specif

Re: [go-nuts] How to encode/decode string to binary in golang

2023-03-14 Thread Van Fury
t; > return errors.Wrap(err, "decodeGob") > } > > Op dinsdag 14 maart 2023 om 00:06:31 UTC+1 schreef robert engels: > >> Am arbitrary byte can be encoded in 2 HEX characters - only a 2x increase >> in size not 8x. >> >> On Mar 13, 2023, at 2:35 PM,

Re: [go-nuts] How to encode/decode string to binary in golang

2023-03-13 Thread Van Fury
rver which then decodes the raw binary back to s1+s2. On Mon, Mar 13, 2023 at 5:39 PM Van Fury wrote: > Do you mean encoding should be > rawdata := fmt.Print("%016d%s%s", len(s1), s1,s2) > or > rawdata := fmt.Printf("%016d%s%s", len(s1), s1,s2) > > > > On Monday,

Re: [go-nuts] How to encode/decode string to binary in golang

2023-03-13 Thread Van Fury
g.go.dev/strconv#ParseUint > > https://go.dev/play/p/qAO9LfLD41D > > On Mon, 13 Mar 2023 at 07:24, Van Fury wrote: > >> >> Sorry I did not frame my question properly but what I would like to do is >> to >> encode concatenated s1 and s2 into raw binary and then de

Re: [go-nuts] How to encode/decode string to binary in golang

2023-03-13 Thread Van Fury
ust slice up the decoded > string based on the lengths. If they are of a variable length, you'll need > a separator in the input string to later split on when decoded (s3 := s1 + > ":" + s2 etc)? > > On Fri, 10 Mar 2023 at 10:33, Van Fury wrote: > >> Hi, >&

[go-nuts] How to encode/decode string to binary in golang

2023-03-10 Thread Van Fury
Hi, I have two hexadecimal string values and would like to concatenate the two strings and 1. encode the result to binary 2. decode the resulting binary back to hexadecimal string I did the following but I was finding it difficult to decode the result back. I ignore error check in this

Re: [go-nuts] Delete from map failed golang

2021-11-19 Thread Van Fury
ng]AuthCtx) I would like to CtxStarStore would be access globally. Is there a better way to initialize it. Thanks for the response. -- Fury On Friday, November 19, 2021 at 6:09:04 PM UTC+2 Kurtis Rader wrote: > On Fri, Nov 19, 2021 at 7:17 AM Van Fury

[go-nuts] Delete from map failed golang

2021-11-19 Thread Van Fury
Hi I have a map as shown below var CtxStarStore = make(map[string]AuthCtx) map[ccc-999401002:{989c48c5-7f9c-4058-80a2-b769ea4675f9 imei-1234010002} bbb -999401003:{989c48c5-7f9c-4058-80a2-b769ea4675f9 imei-1234010003}] I would like to delete ccc-999401002 or any key value from the map I

Re: [go-nuts] HTTP request matching different endpoint - gorilla mux

2021-09-02 Thread Van Fury
; where id=shared_data. You can use a regex for the path >> with {id} to exclude the "shared_data" match. >> >> On Thu, Sep 2, 2021 at 10:13 AM Van Fury wrote: >> >>> Hi All, >>> >>> I have the following to handler functions, DataSetsGet and &

[go-nuts] HTTP request matching different endpoint - gorilla mux

2021-09-02 Thread Van Fury
Hi All, I have the following to handler functions, DataSetsGet and RetrieveSharedData. When make request with the URL https://127.0.0.1:2/nfdm-fdm/v2/shared-data, I get response from DataSetsGet handler instead of RetrieveSharedData handler function. When I take the bracket from {id} to

[go-nuts] How to handle HTTPS between go reverse proxies

2021-06-04 Thread Van Fury
Hi, Am using "net/http/httputil" Reverse proxy and would to make HTTPS forwarding between the two proxy servers. Any help on how to handle HTTPS between the proxy servers instead of HTTP? Here are a sample of my code. Proxy A func main() { http.HandleFunc("/", proxyPassA)

[go-nuts] Re: How to a JSON is contain in an array JSON objects in golang

2021-05-25 Thread Van Fury
excuse the formatting - I'm on my phone). > > On Monday, 24 May 2021 at 16:44:34 UTC+1 Van Fury wrote: > >> Hi, >> >> I have an array of JSON objects as >> >> Structs: >> ``` >> type Data struct { >> TaiList []Tai `json:"taiList"` >>

[go-nuts] How to a JSON is contain in an array JSON objects in golang

2021-05-24 Thread Van Fury
Hi, I have an array of JSON objects as Structs: ``` type Data struct { TaiList []Tai `json:"taiList"` } type Tai struct { PlmnId *PlmnId `json:"plmnId"` Tac string `json:"tac"` Nid string `json:"nid"` } type PlmnId struct { Mcc string `json:"mcc"` Mnc string

[go-nuts] How to write new data to http.ResponseWriter

2021-04-26 Thread Van Fury
Hi, I would like to implement an HTTP request and response system of this flow below client --> A --> B > (request) HTTPserver client <-- A <-- B < (response) HTTPserver 1. client send HTTP request with any HTTP method (POST,PUT, etc) to A 2. A

[go-nuts] Re: HTTP Proxy in Go

2021-04-22 Thread Van Fury
t) { // Decrypt Request here // ... url, _ := url.Parse(Server) proxy := httputil.NewSingleHostReverseProxy(url) proxy.ServeHTTP(res, req) } On Thursday, April 22, 2021 at 4:55:26 PM UTC+3 wilk wrote: > On 22-04-2021, Van Fury wrote: > > --=_Part_322_998422299

[go-nuts] HTTP Proxy in Go

2021-04-22 Thread Van Fury
Hi, I have to implement an HTTP forwarding proxy in Go which can be used in production and need advice from Go experts. Any advice like which Go library is best to use and other things to take not of when implementing it. BR Abraham -- You received this message because you are subscribed

[go-nuts] Re: HTTP routes in different Packages

2021-04-06 Thread Van Fury
"I have two other packages, example.go and user.go" - I mean these files example.go and user.go are in different directories not the same package, and have the package names "package example" and "package user". The main.go is also in different directory with "package main". On Tuesday, April

[go-nuts] HTTP routes in different Packages

2021-04-06 Thread Van Fury
HI, I have the following settings in my REST API program packages: In "routers.go" type Route struct { Namestring Method string Pattern string HandlerFunc http.HandlerFunc } var Router = NewRouter() type Routes []Route func NewRouter() *mux.Router {

[go-nuts] Re: How to design HTTP request between HTTP servers

2021-03-21 Thread Van Fury
Hi, I have found the problem to the double PUT message being sent and have solve it. Thanks for the help. A lot of lesson learnt from this exercise. On Sunday, March 21, 2021 at 1:47:07 PM UTC+2 Brian Candler wrote: > On Sunday, 21 March 2021 at 11:42:37 UTC Brian Candler wrote: > >> Also:

[go-nuts] Re: How to design HTTP request between HTTP servers

2021-03-21 Thread Van Fury
Hi, Line line 147 of register.go is status code check in the second for loop but now solved. if res.StatusCode != http.StatusNoContent { But i still could not find out why the SendNFInstanceRegistration() message is send twice even though i have check the responses here

[go-nuts] Re: How to design HTTP request between HTTP servers

2021-03-21 Thread Van Fury
e if status == http.StatusCreated || status == http.StatusOK { break } } ticker := time.NewTicker(time.Duration(interval) * time.Second) for _ = range ticker.C { res, err := SendHeartbeat(cl) if err != nil { logrus.Error(err

[go-nuts] Re: How to design HTTP request between HTTP servers

2021-03-20 Thread Van Fury
OK, if I understand you correctly, the outer for loop is not needed and that there should be two for loops. the first for loop does step 1,2 and 3 and then "break" out of the loop when valid response is received and then set the "interval". The second for loop start a for _ := range ticker.C loop

[go-nuts] Re: How to design HTTP request between HTTP servers

2021-03-20 Thread Van Fury
Hi Brian, Thanks for the reply. I intentionally left the error checks out so as to make the code short. Also using the Client.Do was an error and its suppose to be transport.Client.Do. Also in the main() does other stuff after the PUT and PATCH messages but does not have any function that is