-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
405 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2017-2023, Gerasimos (Makis) Maropoulos ([email protected]) | ||
Copyright (c) 2017-2024, Gerasimos (Makis) Maropoulos ([email protected]) | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module github.com/kataras/golog/_examples/ngrok-logger | ||
|
||
go 1.21 | ||
|
||
replace github.com/kataras/golog => ../../ | ||
|
||
require ( | ||
github.com/kataras/golog v0.0.0-00010101000000-000000000000 | ||
golang.ngrok.com/ngrok v1.7.0 | ||
xorm.io/xorm v1.3.6 | ||
) | ||
|
||
require ( | ||
github.com/go-stack/stack v1.8.1 // indirect | ||
github.com/inconshreveable/log15 v3.0.0-testing.3+incompatible // indirect | ||
github.com/inconshreveable/log15/v3 v3.0.0-testing.5 // indirect | ||
github.com/jpillora/backoff v1.0.0 // indirect | ||
github.com/kataras/pio v0.0.13 // indirect | ||
github.com/mattn/go-colorable v0.1.13 // indirect | ||
github.com/mattn/go-isatty v0.0.16 // indirect | ||
go.uber.org/multierr v1.11.0 // indirect | ||
golang.ngrok.com/muxado/v2 v2.0.0 // indirect | ||
golang.org/x/net v0.15.0 // indirect | ||
golang.org/x/sync v0.3.0 // indirect | ||
golang.org/x/sys v0.16.0 // indirect | ||
golang.org/x/term v0.12.0 // indirect | ||
google.golang.org/protobuf v1.31.0 // indirect | ||
) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/kataras/golog" | ||
|
||
"golang.ngrok.com/ngrok" | ||
"golang.ngrok.com/ngrok/config" | ||
"golang.ngrok.com/ngrok/log" | ||
) | ||
|
||
// $ go get golang.ngrok.com/ngrok@latest | ||
// $ go run main.go | ||
|
||
type ngrokLoggerAdapter struct { | ||
logger *golog.Logger | ||
} | ||
|
||
// Log(context context.Context, level LogLevel, msg string, data map[string]interface{}) | ||
|
||
// Log implements the ngrok.Logger interface. | ||
func (l *ngrokLoggerAdapter) Log(context context.Context, level log.LogLevel, msg string, data map[string]interface{}) { | ||
l.logger.Info(msg, golog.Fields(data)) | ||
} | ||
|
||
func main() { | ||
logger := golog.New() | ||
|
||
tun, err := ngrok.Listen(context.Background(), | ||
config.HTTPEndpoint( | ||
config.WithDomain("domain.com"), | ||
// config.WithMutualTLSCA(ca), | ||
config.WithForwardsTo("http://localhost:80"), | ||
config.WithCircuitBreaker(0.8), | ||
// config.WithCompression(), | ||
// config.WithProxyProto(config.ProxyProtoV2), | ||
config.WithScheme(config.SchemeHTTPS), | ||
), | ||
ngrok.WithLogger(&ngrokLoggerAdapter{logger: logger /* OR golog.Default */}), | ||
ngrok.WithAuthtoken("NGROK_AUTH_TOKEN"), | ||
// ngrok.WithServer("tunnel.ngrok.com:443"), | ||
ngrok.WithRegion("us"), | ||
) | ||
if err != nil { | ||
logger.Fatal(err) | ||
} | ||
defer tun.Close() | ||
|
||
fmt.Println(tun.URL()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
github.com/kataras/pio v0.0.13 h1:x0rXVX0fviDTXOOLOmr4MUxOabu1InVSTu5itF8CXCM= | ||
github.com/kataras/pio v0.0.13/go.mod h1:k3HNuSw+eJ8Pm2lA4lRhg3DiCjVgHlP8hmXApSej3oM= | ||
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= | ||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= | ||
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= |