Skip to content

Logged request URLs contain duplicate host/port (e.g., "http://example.comhttp://example.com/api") #72

@seb-schulz

Description

@seb-schulz

Problem:
When using httplog with structured logging (e.g., SchemaGCP), the requestUrl field in logs incorrectly duplicates the host and port:

{
  "httpRequest": {
    "requestUrl": "http://localhost:8080http://localhost:8080/api/users",  // ❌ Duplicated
    "requestMethod": "GET",
    "requestPath": "/api/users"
  }
}

Expected:

{
  "httpRequest": {
    "requestUrl": "http://localhost:8080/api/users",  // ✅ Correct
    "requestMethod": "GET",
    "requestPath": "/api/users"
  }
}

How to Reproduce:

var requestLogger = httplog.RequestLogger(slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
	Level: slog.LevelInfo,
})), &httplog.Options{
	Level:         slog.LevelInfo,
	RecoverPanics: true,
	Schema:        httplog.SchemaGCP,
})
  1. Use the logger middleware in your application.
  2. Make a request to any endpoint.
  3. Check the logs: The requestUrl field will show the host/port twice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions