Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 14:21
    shlinym commented #2311
  • 14:19
    shlinym commented #2315
  • 14:03
    shlinym commented #2317
  • 07:20
    Kyocfe edited #2317
  • 04:44
    Kyocfe edited #2317
  • 04:41
    Kyocfe opened #2317
  • 04:32
    codecov[bot] commented #2316
  • 04:31
    Coverage (#2316) +0.00%
  • 04:31
    codecov[bot] commented #2316
  • 04:31
    Coverage (#2316) +0.00%
  • 04:31
    codecov[bot] commented #2316
  • 04:31
    Coverage (#2316) +0.00%
  • 04:26
    codecov[bot] commented #2316
  • 04:26
    Coverage (#2316) +0.00%
  • 04:26
    codecov[bot] commented #2316
  • 04:26
    Coverage (#2316) +0.00%
  • Apr 07 15:07
    codecov[bot] commented #2316
  • Apr 07 15:07
    Coverage (#2316) -0.09%
  • Apr 07 15:07
    codecov[bot] commented #2316
  • Apr 07 15:07
    Coverage (#2316) -0.09%
Shaurya
@shaurya-xyz

Can I use GIN to create a custom URI scheme:

Hi, Does anyone know of good resource to understand how create URI Scheme ?

I am looking at a custom URI scheme such as this custom://{resource}

Server would serve using the above endpoint and client would have to connect the custom endpoint
Any documentation or resource in any language would be helpful
Thanks!

Justin Lewis
@SaviourSelf
Is it possible to intercept and manipulate a response in Gin?
Seyidna Ali
@seyidnaali
hello
Phillip Couto
@phillipCouto
@shaurya-xyz as long as the protocol is http/https then you are fine. Gin uses http requests to route the request and create the response based on your routes and middleware
@SaviourSelf can you elaborate on what you mean by intercept?
Miguel Rodríguez Crespo
@miguelrcDEV
Hi! Anyone knows how to protect a route that serve static files on gin? I want to send a header with token, and if its valid, then serve files. router.StaticFS("/streaming2", http.Dir(mediaPath+"/live"))
Miguel Rodríguez Crespo
@miguelrcDEV
Forget it, I have solved it as follows, in case someone else is interested: streamingRoutes := router.Group("/streaming", AuthHandler()) streamingRoutes.StaticFS("/", http.Dir(mediaPath+"/live"))
JavierFigueroa11
@JavierFigueroa11
How do I do a test on this structure? Using the testing library; give me an example?
type Characters []struct {
CharID int json:"char_id"
Name string json:"name"
Birthday string json:"birthday"
Occupation []string json:"occupation"
Img string json:"img"
Status string json:"status"
Nickname string json:"nickname"
Appearance []int json:"appearance"
Portrayed string json:"portrayed"
Category string json:"category"
BetterCallSaulAppearance []interface{} json:"better_call_saul_appearance"
}
Phillip Couto
@phillipCouto
@JavierFigueroa11 can you elaborate more on what testing you want to perform? Like do you want to test the structure being populated from unmarshalling JSON as an example?
JavierFigueroa11
@JavierFigueroa11
Yes of course
screaming
@sharepusher

Not sure if this is the right place to ask for help. I am using Go and Gin (new to both) to build a backend service. When I received the clients request, I have to response with a complex XML data structure. I have finished the data part.

Here is the format that I'd like to send back:
<?xml version="1.0" encoding="UTF-8"?> -------- the xml declaration part

<Response> ---------the data part
<complexStructure>data</complexStructure>
</Response>

I try using c.Context ... ie. c.XML(200, complexDataStructure), it's convenient and great but I don't know how to make it include and response the declaration part together with the data part.

Any help is appreciated.

Phillip Couto
@phillipCouto
@sharepusher follow the documentation on https://golang.org/pkg/encoding/xml/ to create structures with the necessary metadata to get the XML output you are looking for
You are probably going to need a structure that looks something like go type Response struct { complexStructure ComplexStructure ... additional data }
@JavierFigueroa11 you want to write unit tests, read the documentation from the golang project as a starting point to create proper unit tests and then if you still need help let me know
https://golang.org/doc/code.html#Testing
screaming
@sharepusher
So there's no tricky way to make it current gin interface? And I have to use the official lib directly. Thanks for your clarification.
Phillip Couto
@phillipCouto
@sharepusher gin is using the official limb underneath so you need to create your structure in a way that the encoding/xml package will understand to output the XML you want. Then gin will output the correct XML from your route using c.XML
Quang Mai
@qmn1711
Hi guys, How can I profile and monitor a gin web app?
Like determine which requests are longest, how does often it occur...
screaming
@sharepusher
@phillipCouto Yes, I do make the data structure, and the c.XML can output the data properly, my problem is how to include the header "<?xml version="1.0" encoding="UTF-8"?> " which is not a part of the data.
Mahdi Mozaffari
@Mahd1mz_twitter
hello i have problem to login into web site that require captcha code
can any one help me to solve it
Phillip Couto
@phillipCouto
@sharepusher just add this to your code:
import "encoding/xml"
...
// Put this before everywhere you are calling c.XML
c.Writer.WriteString(xml.Header)
@Mahd1mz_twitter can you explain the problem further? Are you trying to integrate captcha?
Mahdi Mozaffari
@Mahd1mz_twitter
@phillipCouto all i want is parse the web site html code and then get the link of img that is in this code :
(<img alt="Captcha" id="imgcpatcha" class="loginCpatcha" src="/Auth/Captcha" />)
and save it in harddisk then send the captcha code,username and password with postform function for login into web site
my code is:
code.png
Clarke Vennerbeck
@TheKLARKEN

Can I bother you all for some advice? I'm using Gin and Axios (with Vue) to try to post from localhost:8080 (Axios) to localhost:8081 (the Go server).

I'm getting CORS errors despite trying everything in this chat, everything I can find on Stack Overflow, on blog posts, in GitHub issues for Gin, Axios, etc., but I'm having no luck. I've spent about 8 hours on this and have even tried refactoring my whole project, using custom handlers, headers, etc.

Do you have any advice? Thank you so much for taking time to read this!

Clarke Vennerbeck
@TheKLARKEN

God bless the rubber-ducky effect. :pray:

It turns out I simply failed to publish port 8081 on my development container. 8 hours of hitting my head against the wall for something simple. Haha! Hahaaa...

... :sob:

JavierFigueroa11
@JavierFigueroa11
How do I solve this problem?
Captura de pantalla de 2020-03-14 23-53-07.png
How do I solve this problem?
Phillip Couto
@phillipCouto
Try reloading vs code
Gilberto Cuba
@gcubar
@JavierFigueroa11 where are defined “characters” variable? Without this info we couldn’t help you. Sorry! In another instance, in DeleteCharactersID function c variable of type domain.CharactersBB is not initialized, then it will return an error when its compared inside for loop.
JavierFigueroa11
@JavierFigueroa11
Var Characters [] domain.CharactersBB is a global variable
Gilberto Cuba
@gcubar
Well @JavierFigueroa11 , you have declared an array of CharactersBB when CharactersBB are an array too of defined structure. Then characters global variable is an array of two dimensions, and you are trying to access to only one of them from the for loop.
You must define you CharactersBB type as a simple type or your global variable characters of basic CharactersBB type.
I hope it has helped you.
Si, I suspect this has nothing to do with gin framework. :)
JavierFigueroa11
@JavierFigueroa11
Thank you!!👏
Seyidna Ali
@seyidnaali
hello
how to send jwt token to localstroage ?
Phillip Couto
@phillipCouto
@seyidnaali do you mean localstorage in the browser or storing on disk in the server?
Seyidna Ali
@seyidnaali
@phillipCouto in the browser
I user Graphql on gin-go
func New() {

    router := gin.Default()

    router.Use(CORSMiddleware())
    // router.Use(MyCustomMiddleWare())
    router.Use(gin.Logger())
    router.Use(gin.Recovery())

    router.GET("/graphql", graphql.Handler())
    router.POST("/graphql", graphql.Handler())
    router.Run(":5000")

}
Phillip Couto
@phillipCouto
@seyidnaali that is a frontend question and not related to gin. I am sure a quick search on stackoverflow will give you answers on how to securely store a token in the browser.
Masmoudi
@TnPoDoLsKi
Hi everyone i m implimenting Jwt based authentication in my web application with gin , im so confused i didin't find popular authentication middleware or library
Nayan Jyoti Das
@NayanJD
Hi! I am just new to Go and Gin framework. I just wanted to know how to detect foreign key conflict during insertion. I am using Gorm and Postgres. I want to catch the conflict error and return conflict status code along with an appropriate message.
Nayan Jyoti Das
@NayanJD
Hey! Found a way for that. Seems like for postgres the errors are of type *pq.Error. It contains Message and Code. I am currently checking the Code to detect foreign key violation. If anybody has better suggestion, please let me know.
Evershift
@Evershift1_twitter
Hi everyone! I am trying to understand the best way to create and manage migrations for a postrges database with Gin
I happen to be using GORM, but it looks like their migration support is very limited...
linuxMengfan
@linuxMengfan
How is close response headers "Transfer-Encoding: chunked "? because frontend error. I want try close it.
Kris Carr
@kriscarr_gitlab
Is it possible for gin to automatically pick the correct response renderer based on the "Accept" header? I cannot seem to find a relevant function in the gin.Context, just explicit ones like .JSON(), .XML() etc