Skip to content

daytrader-go: rest - #6

Open
devin-ai-integration[bot] wants to merge 2 commits into
migration/daytrader-gofrom
devin/1794800000-go-rest
Open

devin-ai-integration[bot] wants to merge 2 commits into
migration/daytrader-gofrom
devin/1794800000-go-rest

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Ports the JAX-RS address book (daytrader3-ee6-rest: AddressBook, Address, AddressList, AddressBookDatabase) to daytrader-go/internal/features/rest/. Only that directory is touched.

What was ported

  • GET /rest/addresses and GET /rest/addresses/search/{searchstring} (prefix match): {"addresses":[{entryName, zipCode, streetAddress, city, state, country}]}, application/json. The bodies are byte-identical to Liberty's, including the list order (Entry4, Entry5, Entry2, Entry3, Entry1): the store keeps the legacy java.util.HashMap iteration order (bucket, then insertion) so the order is fixed and the same.
  • /rest/addresses/{entryName} keeps the recorded quirk. It is a sub-resource locator onto Address.get, which is @Consumes text/xml | x-www-form-urlencoded, @Produces text/xml:
unknown entry                         -> 404 (any method)
GET without one of those Content-Types -> 415   <- what a plain GET gets (transcript 13)
Accept excludes text/xml              -> 406
otherwise                             -> 204   (legacy compares List<MediaType> to a String and returns null)
  • The legacy resource has no POST/PUT/DELETE, so none were added. Those verbs answer as Liberty does: an empty 405 with Allow: HEAD, GET, OPTIONS (404 for an unknown entry). OPTIONS returns the same WADL document, and Accept that excludes JSON on list/search is 406.
  • The address book stays in memory, as in legacy (a static map, never persisted). There are no writes, so nothing uses app.Store.
  • Routes are registered with web.RegisterRestRoute without a method in the pattern, because net/http's own 405 has a body and a different Allow header.

Parity

make parity printed PASS for 11-rest-list, 12-rest-search, 13-rest-entry:

  • on this branch alone, and
  • on a local throwaway merge of this branch + go-account, go-auth, go-infra, go-market (the siblings on origin at the time). In that combination 01, 02, 03, 08, 09, 10, 11, 12, 13 passed; 04 and 05 were DIFF and 06 and 07 ERROR (trading was not pushed yet; not this area).

Legacy on Liberty was 13/13 on the same machine. Beyond the scenarios, 40 curl probes (methods, Accept/Content-Type combinations, trailing slashes, unknown paths) were diffed between :9083 and :8080: status, body, Content-Type, Allow and Content-Language are identical.

Gates (as run): gofmt -l . empty, go vet ./... clean, go test ./... ok (httptest unit tests in the rest package). docker build and terraform validate were not run; they are not part of this area.

Differences from legacy

  • Content-Length: 0 is not sent on 204 responses (Go's net/http omits it), and is sent on the HEAD 415 where Liberty omits it. No X-Powered-By / Connection: Close headers.
  • Not deliberate behaviour changes otherwise.

Scaffold requests

  • None needed. One note for integration: this package registers /{unmatched...} under the REST root so unknown /rest/* paths answer Liberty's empty 404 instead of Go's 404 page not found text. No other area should register REST routes, so it cannot conflict.

Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/076ce1e56d8448778a35bbfff91ad70a
Open in Devin Desktop: https://partner-workshops.devinenterprise.com/desktop/session/076ce1e56d8448778a35bbfff91ad70a?variant=devin
Requested by: @sumitshatwara

@devin-ai-integration

Copy link
Copy Markdown
Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant