mirror of
https://github.com/Maronato/go-finger.git
synced 2025-03-15 00:34:47 +00:00
fix debug logging and map urn
This commit is contained in:
parent
0555bb3fe4
commit
6f4d6e074a
1 changed files with 6 additions and 10 deletions
12
main.go
12
main.go
|
@ -43,10 +43,6 @@ func Run() error {
|
||||||
|
|
||||||
cfg := &Config{}
|
cfg := &Config{}
|
||||||
|
|
||||||
// Create a logger and add it to the context
|
|
||||||
l := NewLogger(cfg)
|
|
||||||
ctx = WithLogger(ctx, l)
|
|
||||||
|
|
||||||
// Create a new root command
|
// Create a new root command
|
||||||
subcommands := []*ff.Command{
|
subcommands := []*ff.Command{
|
||||||
NewServerCmd(cfg),
|
NewServerCmd(cfg),
|
||||||
|
@ -74,7 +70,9 @@ func NewServerCmd(cfg *Config) *ff.Command {
|
||||||
Usage: "serve [flags]",
|
Usage: "serve [flags]",
|
||||||
ShortHelp: "Start the webfinger server",
|
ShortHelp: "Start the webfinger server",
|
||||||
Exec: func(ctx context.Context, args []string) error {
|
Exec: func(ctx context.Context, args []string) error {
|
||||||
l := LoggerFromContext(ctx)
|
// Create a logger and add it to the context
|
||||||
|
l := NewLogger(cfg)
|
||||||
|
ctx = WithLogger(ctx, l)
|
||||||
|
|
||||||
// Parse the webfinger files
|
// Parse the webfinger files
|
||||||
fingermap, err := ParseFingerFile(ctx, cfg)
|
fingermap, err := ParseFingerFile(ctx, cfg)
|
||||||
|
@ -310,12 +308,10 @@ func ParseFingerFile(ctx context.Context, cfg *Config) (WebFingerMap, error) {
|
||||||
for field, value := range v {
|
for field, value := range v {
|
||||||
fieldUrn := field
|
fieldUrn := field
|
||||||
|
|
||||||
// If the key is not already an URN, try to find it in the URNs file
|
// If the key is present in the URNs file, use the value
|
||||||
if _, err := url.Parse(field); err != nil {
|
|
||||||
if _, ok := urnMap[field]; ok {
|
if _, ok := urnMap[field]; ok {
|
||||||
fieldUrn = urnMap[field]
|
fieldUrn = urnMap[field]
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// If the value is a valid URI, add it to the links
|
// If the value is a valid URI, add it to the links
|
||||||
if _, err := url.Parse(value); err == nil {
|
if _, err := url.Parse(value); err == nil {
|
||||||
|
|
Loading…
Add table
Reference in a new issue