[go-nuts] oauth2 for openAPI

2018-12-17 Thread afriyie . abraham
Hi, am new to go language and need help or ideas as how i can write a server oauth2 to have a client authenticated.. If there is an already code or if i have to write my own then please help with the guidlines of how write it The client have to send a POST request and get authenticated and then

[go-nuts] Patch method

2019-01-08 Thread afriyie . abraham
Hi, Am new in Go programming and need help to write a PATCH method for my go-server. my data field look like these type NFProfile struct { NFType string `json:"nftype"` NFInstanceID string `json:"instanceid"` NFStatus string `json:"nfstatus"` ID string `json:"id"` }

[go-nuts] How to rewrite code and apply middleware gorilla mux routes

2019-04-03 Thread afriyie . abraham
Hi I have this working main function code and would like to rewrite it such that the middleware "validateToken" would be applied to all my gorilla mux routes. Please attached is the file containg the working code. What i would like to do is to use the handler function

[go-nuts] Re: How to rewrite code and apply middleware gorilla mux routes

2019-04-03 Thread afriyie . abraham
On Wednesday, April 3, 2019 at 11:28:55 AM UTC+3, afriyie...@gmail.com wrote: > > Hi > > I have this working main function code and would like to rewrite it such > that the middleware "validateToken" would be applied > to all my gorilla mux routes. > Please attached is the file containg the

[go-nuts] Re: How to rewrite code and apply middleware gorilla mux routes

2019-04-03 Thread afriyie . abraham
On Wednesday, April 3, 2019 at 11:28:55 AM UTC+3, afriyie...@gmail.com wrote: > > Hi > > I have this working main function code and would like to rewrite it such > that the middleware "validateToken" would be applied > to all my gorilla mux routes. > Please attached is the file containg the

[go-nuts] How to write bson.M format Golang

2019-03-26 Thread afriyie . abraham
Hi, Am using mongodb as database. Am able to query the database from the command line using the command db.nfinstances.distinct("ipv4Addresses",{"nfType":"AMF", "amfInfo.amfSetId": "3fa85f64-5717-4562-b3fc-2c963f66af33"}) and this give me ipaddress [x.x.x.x] output that i want. mongo

[go-nuts] How to apply middleware

2019-04-03 Thread afriyie . abraham
Hi, I have this main function in a main.go file inside the main directory func main() { log.Printf("Server started") router := sw.NewRouter() manager := manage.NewDefaultManager() manager.SetAuthorizeCodeTokenCfg(manage.DefaultAuthorizeCodeTokenCfg)

Re: [go-nuts] How to apply middleware

2019-04-04 Thread afriyie . abraham
I have modify the middleware to the below but it only work if the handler function "/protected" is in the main function. I have many handlers and do not want to put all of them in the main.go. You suggest i define a struct and use member function of the struct, can you elaborate more about for

Re: [go-nuts] How to apply middleware

2019-04-04 Thread afriyie . abraham
changing and using "router.Use(getTokenMW(server))" is validating all the routes. How can i exclude routes /oauth2/token and /credentials. I read that populate but i dont get the idea. Any clew about how to go about this? On Wednesday, April 3, 2019 at 6:47:12 PM UTC+3, Burak Serdar wrote: >

Re: [go-nuts] How to apply middleware

2019-04-05 Thread afriyie . abraham
Hi, Yes this make sense and it works. The code also look simple to read. Thanks!! On Thursday, April 4, 2019 at 7:54:27 PM UTC+3, car...@hotmail.com wrote: > > How about something like this? Unsure about concurrent access to global > variables, but if you want to access srv and clientstore

[go-nuts] Re: loop - Help

2019-02-15 Thread afriyie . abraham
hi, This is what i have done so far but still need some help as to how to return ""v.APIVersionInURI" in the loop function (FindAlluris()) . Am trying to write a function which will return all the field ""v.APIVersionInURI" in the mongo db and then use this function in my API handler function.

[go-nuts] loop - Help

2019-02-14 Thread afriyie . abraham
Hi, Am quite new in go language and asking for help. I have this JSON object in mongodb with collection name "COLLECTION", I have multiple object in the database (mongo) and would like to access all the string values """apiVersionInUri": "string", in all the objects. Can anyone help me do this

[go-nuts] Re: loop - Help

2019-02-15 Thread afriyie . abraham
hi, currently am able to get the vlaues but will like to get both key and values, how will i be able to do it. This is output i got now, a slice of the apiVersionInUri", which is corent but want it with the keys, like "apiVersionInUri": "http://instance4.com";, map form [

[go-nuts] Help - Mongodb JSON access

2019-02-19 Thread afriyie . abraham
Hi, I have a json data in mongodb in the format be bellow, i need help to access the data using the "nfinstanceID" which is a uuid string ID part of an api request for example example "http://localhost:5050/nnrf-nfm/v1/nf-instances/3fa85f64-5717-4562-b3fc-2c963f66afaa; The api route is

Re: [go-nuts] Help- Empty request header and body

2019-02-11 Thread afriyie . abraham
Hi, Please attacted is app files (unnecessary codes deleted). I don’t if I could made mode simpler but this is how am able let you identify the problem am encountering when I run this code. I tried to print the request header and body and this is what am getting ] &{{ObjectIdHex("") 0 0

[go-nuts] array output null - help

2019-01-25 Thread afriyie . abraham
Hi, Am trying to write a simple api using gorm and Sqlite3 database. Am using stuct and functions below. However, after "PUT" of JSON format payload using Postman, the instances get created but when try to "GET" all the instances, the array content shows "plmnList : null" without the array key

[go-nuts] how to access request data using global variable -- help

2019-06-10 Thread afriyie . abraham
I have this simple http server. How can i access the request data to a global variable and use it in any other part of my application (example in different function). package main import ( "io" "net/http") var data string // Get http request URL data globally and use it in other

[go-nuts] go app with both diamter and api interface

2019-06-17 Thread afriyie . abraham
Am trying to create an app that can receive an api request and use the api request parameters as input to send a new diameter request to a diamter node. For examplehe diameter interface<- App <-- api interface So the app receive an http request from a client using some url

[go-nuts] Golang - mongodb watch for specific data

2019-05-06 Thread afriyie . abraham
Hi, I have this data or document in mongodb. { "nfInstanceId": "3fa85f64-5717-4562-b3fc-2c963f66af37", "nfType": [ "AMF" ], "nfStatus": [ "string" ], "sNssais": [{ "sst": 1, "sd": "sd1" } ], "nsiList": [ "string" ], "ipv4Addresses": [ "198.51.100.100" ], "allowedNssais": [{

[go-nuts] How to create custom diameter application with go

2019-06-27 Thread afriyie . abraham
Hi all, I cannot see diameter messages of my custom diameter application (Application-ID 16777255, code: 8388620) in Wireshark after modifying the go-diameter example server and client codes. Can you explain why am not seeing my custom application AVPs in Wireshark? What I did was to write a

[go-nuts] Re: Diameter EAP Application - go-diameter

2019-08-28 Thread afriyie . abraham
HkI4mZ7Eg> . Thanks for the hint. Abraham On Wednesday, August 28, 2019 at 10:28:16 AM UTC+3, Afriyie Abraham Kwabena wrote: > > Hi All, > > It it possible to modify the go-diameter package to implement Diameter EAP > Application, that is > instead of the current capabiliti

[go-nuts] Diameter EAP Application - go-diameter

2019-08-28 Thread afriyie . abraham
Hi All, It it possible to modify the go-diameter package to implement Diameter EAP Application, that is instead of the current capabilities exchange request and answer, CER/CEA exchange, i would like to do a DER/DEA request and answer. If possible how would go about it, which files or part of

[go-nuts] how to query mysql hexadecimal value

2019-09-04 Thread afriyie . abraham
I have tried to query mysql database table data but am getting the byte data after trying many instances to convert the byte data to the hexadecimal values. Any help about how can i get the hexadecimal values from the database. I created the table below as CREATE TABLE

Re: [go-nuts] How to query mysql hexadecimal data

2019-09-04 Thread afriyie . abraham
Hi hex.EncodeString works! The problem was the struct field types ([]byte) instead of string. Thanks! On Wednesday, September 4, 2019 at 4:49:46 PM UTC+3, burak serdar wrote: > > On Wed, Sep 4, 2019 at 6:41 AM > > wrote: > > > > > > I have tried to query mysql database table data but am

[go-nuts] How to Unmarshal diameter client different request to different struct at diamter server side

2019-09-11 Thread afriyie . abraham
Hi, Am developing a diameter server using go-diameter package that need to perform EAP-AKA authentication. In the DER/DEA process, the client will be sending multiple request to the server, that is first the client sends an identity request to the server, the server respond with RAND,

[go-nuts] How to perform dynamic unmarsahlling

2019-09-12 Thread afriyie . abraham
Can anyone help me perform dynamic unmarshalling depending on the type of messages received from a diameter client. In the code below, I have to two structures which represent two different messages received by a diameter server. I would like to modify the current code which unmarshals the

[go-nuts] How to handle diamter client different request with one handle at diamter server side

2019-09-11 Thread afriyie . abraham
Hi, Am developing a diameter server using go-diameter package that need to perform EAP-AKA authentication. In the DER/DEA process, the client will be sending multiple request to the server, that is first the client sends an identity request to the server, the server respond with RAND, MAC,

[go-nuts] How to search for string value in array

2019-09-26 Thread afriyie . abraham
I have trying to write a function that will accept a string as an input and return another string in a slice but it not working. I have function that unmarshal udp response to a type AuthVectors and then append the type struct data into an array authVecSlice. Below is the code type

[go-nuts] How to search for string value in array

2019-09-26 Thread afriyie . abraham
I have trying to write a function that will accept a string as an input and return another string in a slice but it not working. I have function that unmarshal udp response to a type AuthVectors and then append the type struct data into an array authVecSlice. Below is the code type

[go-nuts] How to search for string value in array

2019-09-26 Thread afriyie . abraham
I have trying to write a function that will accept a string as an input and return another string in a slice but it not working. I have function that unmarshal udp response to a type AuthVectors and then append the type struct data into an array authVecSlice. Below is the code type

[go-nuts] How to search for string value in array

2019-09-26 Thread afriyie . abraham
I have trying to write a function that will accept a string as an input and return another string in a slice but it not working. I have function that unmarshal udp response to a type AuthVectors and then append the type struct data into an array authVecSlice. Below is the code type

[go-nuts] How to search for string value in array

2019-09-26 Thread afriyie . abraham
I have trying to write a function that will accept a string as an input and return another string in a slice but it not working. I have function that unmarshal udp response to a type AuthVectors and then append the type struct data into an array authVecSlice. Below is the code type

[go-nuts] How to search for string value in array

2019-09-26 Thread afriyie . abraham
I have trying to write a function that will accept a string as an input and return another string in a slice but it not working. I have function that unmarshal udp response to a type AuthVectors and then append the type struct data into an array authVecSlice. Below is the code type

[go-nuts] How to search for string value in array

2019-09-26 Thread afriyie . abraham
I have trying to write a function that will accept a string as an input and return another string in a slice but it not working. I have function that unmarshal udp response to a type AuthVectors and then append the type struct data into an array authVecSlice. Below is the code type

[go-nuts] How to search for string value in array

2019-09-26 Thread afriyie . abraham
I have trying to write a function that will accept a string as an input and return another string in a slice but it not working. I have function that unmarshal udp response to a type AuthVectors and then append the type struct data into an array authVecSlice. Below is the code type

[go-nuts] How to use .toml file to parse IP address and port to http server

2019-09-29 Thread afriyie . abraham
Hi, How I can use the .toml file to parse IP address and port to simple http server instead of using flags I have a config.toml file which contains these parameters in PORT = "8000" Address = "localhost" //Parameters type struct as type Config struct { PORTstring Address string } I can

Re: [go-nuts] How to use .toml file to parse IP address and port to http server

2019-09-30 Thread afriyie . abraham
Hi, I have applied similar scenario to the function below but am not getting the Ip address and the port number. Below is the function var addr string func init(){ var conf Config if _, err := toml.Decode("config.toml", ); err != nil { // handle error } addr =

Re: [go-nuts] How to use .toml file to parse IP address and port to http server

2019-09-30 Thread afriyie . abraham
Hi, I have solve the problem and it works now. Thanks. On Monday, September 30, 2019 at 11:06:20 AM UTC+3, Afriyie Abraham Kwabena wrote: > > Hi, > > I have applied similar scenario to the function below but am not getting > the Ip address and the port number. Below is the f

[go-nuts] How to query mongodb dynamically using Go interface

2020-01-16 Thread afriyie . abraham
Hi, I have been trying to create a dynamic mongodb query using golang interface but the logical $or does not work. It only return a documents when the input matches the bson.M{"sNssais.sst": args[0].(int32), "sNssais.sd": args[1].(string)}. other matches like bson.M{"amfInfo.taiList.tac":

[go-nuts] Re: How to query mongodb dynamically using Go interface

2020-01-16 Thread afriyie . abraham
": "string" }, "tac": "3022", "nid": "string" }], }, "customInfo": {} } The args in the *.tac are string values, even if i set the type casting like bson.M{"amfInfo.taiList.ta

[go-nuts] Re: How to query mongodb dynamically using Go interface

2020-01-17 Thread afriyie . abraham
Hi, The problem wa about the index, i solved it by using the right index bson.M{"amfInfo.taiList.tac": args[2]} since the fuction is called Da.FindIp(targetNfType, sst, sd, tac) Thanks! On Thursday, January 16, 2020 at 5:04:40 PM UTC+2, Afriyie Abraham Kwabena wrote: > > Hi,

[go-nuts] How to query mongodb

2020-01-17 Thread afriyie . abraham
Hi I have in my collection this JSON { "allowedSnssaiList": [ { "allowedSnssai": { "sst": 1, "sd": "1" }, "allowedSnssai": { "sst": 2, "sd": "3" } } ] } how can query using the key sst and sd to return a documents matching the two exact values? Example when i query using sst:1, sd

Re: [go-nuts] How to detect HTTP client stop polling at the server side

2020-11-27 Thread Afriyie Abraham Kwabena
Hi, THanks!! BR Abraham On Friday, November 27, 2020 at 11:12:53 AM UTC+2 b.ca...@pobox.com wrote: > On Friday, 27 November 2020 at 06:14:48 UTC Afriyie Abraham Kwabena wrote: > >> What I would like to ask is, using mutex OK and if not the best way of >> solving it, how can

Re: [go-nuts] How to detect HTTP client stop polling at the server side

2020-11-26 Thread Afriyie Abraham Kwabena
if err != nil { config.Logrus.Error(err) } delete(idtime, keyid) } } mu.Unlock() } } BR Abraham On Wednesday, November 18, 2020 at 10:51:49 AM UTC+2 Afriyie Abraham Kwabena wrote: > Hi Sulhan, Anderson, > > Th

Re: [go-nuts] How to detect HTTP client stop polling at the server side

2020-11-26 Thread Afriyie Abraham Kwabena
common.WriteError(response, common.ErrMethodNotAllowed) return } } BR Abraham On Friday, November 27, 2020 at 6:38:52 AM UTC+2 Shulhan wrote: > > > > On 27 Nov 2020, at 07.06, Afriyie Abraham Kwabena > wrote: > > > > Hi, > > > > Am exp

Re: [go-nuts] How to detect HTTP client stop polling at the server side

2020-11-26 Thread Afriyie Abraham Kwabena
+0x11e net/http.(*conn).serve() /usr/local/go/src/net/http/server.go:1834 +0x1d5b Goroutine 18 (running) created at: main.main() /home/xxx/go/src/nfnrfapi/main.go:41 +0x2c6 On Friday, November 27, 2020 at 8:14:48 AM UTC+2 Afriyie Abraham Kwabena wrote: > Hi, > >

[go-nuts] How to detect HTTP client stop polling at the server side

2020-11-14 Thread Afriyie Abraham Kwabena
Hi, My question is about multiple HTTP client polling an HTTP server randomly with a PATCH request to update a resource at the server running in front of MongoDB. The clients poll with their different ids and a valid time in their request. At the server, I can keep their ids and their

Re: [go-nuts] How to detect HTTP client stop polling at the server side

2020-11-16 Thread Afriyie Abraham Kwabena
wrote: > > > On 14 Nov 2020, at 20.06, Afriyie Abraham Kwabena > wrote: > > > > Hi, > > > > My question is about multiple HTTP client polling an HTTP server > randomly with a PATCH request to update a resource at the server running in > front of MongoDB.

[go-nuts] How to detect if transport connection break

2020-11-20 Thread Afriyie Abraham Kwabena
Hi, My basic understanding of HTTP protocol is that an HTTP client sent request, get response from the HTTP server and then the connection is closed. My question is how can an HTTP client detect if the underling transport connection break. For example if the HTTP server shutdown, is there a

Re: [go-nuts] How to detect if transport connection break

2020-11-20 Thread Afriyie Abraham Kwabena
Hi, Am new to programming and if you could explain further what you mean by long lived process. On Friday, November 20, 2020 at 11:41:42 AM UTC+2 amits...@gmail.com wrote: > > > On Fri, 20 Nov 2020, 7:51 pm Afriyie Abraham Kwabena, < > afriyie...@gmail.com> wrote: > >

Re: [go-nuts] How to detect if transport connection break

2020-11-20 Thread Afriyie Abraham Kwabena
Hi, Yes, that is what intend to implement. Can you help with some information about how I could implement it. If possible some libraries or example code. Abraham On Friday, November 20, 2020 at 1:07:12 PM UTC+2 Afriyie Abraham Kwabena wrote: > Hi, > > Am new to programming and if

Re: [go-nuts] How to detect HTTP client stop polling at the server side

2020-11-18 Thread Afriyie Abraham Kwabena
>= 60 { // delete resouce in database after 60 seconds _ = DeleteNFInstance(ctx, keyid) } } mu.Unlock() } } BR Abraham On Tuesday, November 17, 2020 at 9:41:01 PM UTC+2 Shulhan wrote: > > > > On 18 Nov 2020, at 01.06,

Re: [go-nuts] How to detect HTTP client stop polling at the server side

2020-11-17 Thread Afriyie Abraham Kwabena
ve the 3 servers tracking the same > client. It might happen server A doesn't receive any request from the > client for a while, but not because the client isn't pooling any more, but > because all requests are being directed to either B or C. > > On Tuesday, 17 November 2020 at

Re: [go-nuts] How to detect HTTP client stop polling at the server side

2020-11-17 Thread Afriyie Abraham Kwabena
On Tuesday, November 17, 2020 at 3:48:44 PM UTC+2 Shulhan wrote: > Hi Afriyie, > > Looks like you almost there ;) > > > On 17 Nov 2020, at 20.11, Afriyie Abraham Kwabena > wrote: > > > > HI, > > > > This is what I have tried so far but am not able

Re: [go-nuts] How to detect HTTP client stop polling at the server side

2020-11-17 Thread Afriyie Abraham Kwabena
func main() { > r := NewRouter() > > go worker() > > > fmt.Println("Start listening") > fmt.Println(http.ListenAndServe(":8080", r)) > } > > I appreciate your help but am still not able to it work. > > > On Tuesday, Nov

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

2021-03-20 Thread Afriyie Abraham Kwabena
Hi, I have been learning Golang for some few months now but still find it difficult to design some applications. I have two HTTP servers A and B and would like to do the following 1. server A send an HTTP PUT request with JSON body to server B. 2. If server B is not available, server A retry