-
Notifications
You must be signed in to change notification settings - Fork 3
93 api rss feed tbv status updates #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pasibun
wants to merge
15
commits into
main
Choose a base branch
from
93-api-rss-feed-tbv-status-updates
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a54d289
feat(api): add RSS feed endpoint for API content changes and related …
pasibun ccdff17
fix(api): enforce HTTPS scheme in absoluteRequestURL function [deploy…
pasibun 2d7f462
feat(api): update RSS feed URLs and refactor URL handling functions […
pasibun 984019b
feat(api): enhance URL normalization for public API hosts in request …
pasibun f78f1d2
feat(api): add RSS feed entry and remove obsolete implementation model
pasibun f023806
Potential fix for pull request finding
pasibun 690cd6e
fix: use PUBLIC_API_BASE_URL env var for RSS feed atom self-link to p…
Copilot 54d2591
fix: correct grammar in changelog entry
Copilot 8335f11
feat(api): enforce PUBLIC_API_BASE_URL requirement for RSS feed and u…
pasibun 68bfac9
fix(api): update document hierarchy levels in Typesense indexing and …
pasibun c36f010
Update pkg/api_client/services/api_service.go
pasibun 99423ab
fix(api): update RSS feed endpoint to use .rss extension and remove A…
pasibun 8f40950
Merge branch 'main' into 93-api-rss-feed-tbv-status-updates
pasibun 59a36c7
fix(tests): handle nil getByID in stubRepo and update lifecycle statu…
pasibun ef4de62
feat(api): enhance feed event handling with structured titles and des…
pasibun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,3 @@ | ||
| kind: Added | ||
| body: Added an RSS feed for the API. Updates when adrscore, lifecycle, hash changed or oas unavailable. | ||
| time: 2026-05-11T23:03:58.751029+02:00 |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,93 @@ | ||
| package util | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "net/http" | ||
| "strings" | ||
| ) | ||
|
|
||
| const frontendAPIBaseURL = "https://apis.developer.overheid.nl/apis" | ||
|
|
||
|
pasibun marked this conversation as resolved.
|
||
| func FrontendAPIURL(id string) string { | ||
| return fmt.Sprintf("%s/%s", frontendAPIBaseURL, id) | ||
| } | ||
|
|
||
| func AbsoluteCurrentRequestURL(r *http.Request) string { | ||
| if r == nil || r.URL == nil { | ||
| return "" | ||
| } | ||
| if forwardedURI := strings.TrimSpace(r.Header.Get("X-Forwarded-Uri")); forwardedURI != "" { | ||
| return AbsoluteRequestURL(r, forwardedURI) | ||
| } | ||
| if originalURI := strings.TrimSpace(r.Header.Get("X-Original-URI")); originalURI != "" { | ||
| return AbsoluteRequestURL(r, originalURI) | ||
| } | ||
| path := r.URL.RequestURI() | ||
| if strings.TrimSpace(path) == "" { | ||
| path = r.URL.Path | ||
| } | ||
| return AbsoluteRequestURL(r, path) | ||
| } | ||
|
|
||
| func AbsoluteRequestURL(r *http.Request, path string) string { | ||
| if r == nil { | ||
| return "" | ||
| } | ||
| scheme := "https" | ||
| host := r.Host | ||
|
|
||
| if forwardedScheme, forwardedHost := parseForwardedHeader(r.Header.Get("Forwarded")); forwardedScheme != "" || forwardedHost != "" { | ||
| if forwardedScheme != "" { | ||
| scheme = forwardedScheme | ||
| } | ||
| if forwardedHost != "" { | ||
| host = forwardedHost | ||
| } | ||
| } | ||
| if forwarded := strings.TrimSpace(r.Header.Get("X-Forwarded-Proto")); forwarded != "" { | ||
| scheme = strings.Split(forwarded, ",")[0] | ||
| } | ||
| if forwarded := strings.TrimSpace(r.Header.Get("X-Forwarded-Host")); forwarded != "" { | ||
| host = strings.Split(forwarded, ",")[0] | ||
| } | ||
| if prefix := strings.TrimRight(strings.TrimSpace(r.Header.Get("X-Forwarded-Prefix")), "/"); prefix != "" && !strings.HasPrefix(path, prefix+"/") { | ||
| path = prefix + path | ||
| } | ||
| scheme, path = normalizePublicAPIURL(scheme, host, path) | ||
| return fmt.Sprintf("%s://%s%s", strings.TrimSpace(scheme), strings.TrimSpace(host), path) | ||
|
pasibun marked this conversation as resolved.
|
||
| } | ||
|
|
||
| func normalizePublicAPIURL(scheme, host, path string) (string, string) { | ||
| hostWithoutPort := strings.Split(strings.TrimSpace(host), ":")[0] | ||
| switch hostWithoutPort { | ||
| case "api.developer.overheid.nl", "api.don.projects.digilab.network": | ||
| scheme = "https" | ||
| if path == "/v1" || strings.HasPrefix(path, "/v1/") { | ||
| path = "/api-register" + path | ||
| } | ||
| } | ||
| return scheme, path | ||
| } | ||
|
|
||
| func parseForwardedHeader(value string) (string, string) { | ||
| first := strings.TrimSpace(strings.Split(value, ",")[0]) | ||
| if first == "" { | ||
| return "", "" | ||
| } | ||
|
|
||
| var proto, host string | ||
| for _, part := range strings.Split(first, ";") { | ||
| key, val, ok := strings.Cut(strings.TrimSpace(part), "=") | ||
| if !ok { | ||
| continue | ||
| } | ||
| val = strings.Trim(strings.TrimSpace(val), `"`) | ||
| switch strings.ToLower(strings.TrimSpace(key)) { | ||
| case "proto": | ||
| proto = val | ||
| case "host": | ||
| host = val | ||
| } | ||
| } | ||
| return proto, host | ||
| } | ||
This file contains hidden or 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,44 @@ | ||
| package util | ||
|
|
||
| import ( | ||
| "net/http/httptest" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestFrontendAPIURL(t *testing.T) { | ||
| assert.Equal(t, "https://apis.developer.overheid.nl/apis/api-1", FrontendAPIURL("api-1")) | ||
| } | ||
|
|
||
| func TestAbsoluteCurrentRequestURL_UsesForwardedLocation(t *testing.T) { | ||
| req := httptest.NewRequest("GET", "/internal/apis/api-1/feed?format=rss", nil) | ||
| req.Header.Set("Forwarded", `proto=https;host="api.example.test"`) | ||
| req.Header.Set("X-Forwarded-Uri", "/api-register/v1/apis/api-1/feed?format=rss") | ||
|
|
||
| assert.Equal(t, | ||
| "https://api.example.test/api-register/v1/apis/api-1/feed?format=rss", | ||
| AbsoluteCurrentRequestURL(req), | ||
| ) | ||
| } | ||
|
|
||
| func TestAbsoluteCurrentRequestURL_NormalizesPublicAPIHost(t *testing.T) { | ||
| req := httptest.NewRequest("GET", "/v1/apis/MBDp9RTvg/feed", nil) | ||
| req.Host = "api.don.projects.digilab.network" | ||
| req.Header.Set("X-Forwarded-Proto", "http") | ||
|
|
||
| assert.Equal(t, | ||
| "https://api.don.projects.digilab.network/api-register/v1/apis/MBDp9RTvg/feed", | ||
| AbsoluteCurrentRequestURL(req), | ||
| ) | ||
| } | ||
|
|
||
| func TestAbsoluteCurrentRequestURL_NormalizesProductionAPIHost(t *testing.T) { | ||
| req := httptest.NewRequest("GET", "/v1/apis/MBDp9RTvg/feed", nil) | ||
| req.Host = "api.developer.overheid.nl" | ||
|
|
||
| assert.Equal(t, | ||
| "https://api.developer.overheid.nl/api-register/v1/apis/MBDp9RTvg/feed", | ||
| AbsoluteCurrentRequestURL(req), | ||
| ) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.