Documentation
¶
Index ¶
- Variables
- func ListenAndServe(addr string) error
- func LoadDefaultPostcodes() error
- func LoadFile(path string) error
- func LoadJSON(data []byte) error
- func LoadReader(r io.Reader) error
- func LoadRecords(records []PostcodeRecord) error
- func NewClient(opts ...postcode.ClientOption) (*postcode.Client, error)
- func NewHandler() http.Handler
- func NewServer() *httptest.Server
- func NewTransport() http.RoundTripper
- func ResetSimulatedRateLimits()
- type PostcodeRecord
Constants ¶
This section is empty.
Variables ¶
var TestPostcodes []PostcodeRecord
TestPostcodes contains the active in-memory test postcodes.
Functions ¶
func ListenAndServe ¶
ListenAndServe starts a live HTTP server listening on the specified network address.
func LoadDefaultPostcodes ¶ added in v0.1.1
func LoadDefaultPostcodes() error
LoadDefaultPostcodes resets TestPostcodes and indexes to the embedded official dataset.
func LoadFile ¶ added in v0.1.1
LoadFile reads test postcodes from a file path and updates the simulator.
func LoadJSON ¶ added in v0.1.1
LoadJSON loads test postcodes from raw JSON bytes into the simulator.
func LoadReader ¶ added in v0.1.1
LoadReader reads test postcodes from an io.Reader and updates the simulator.
func LoadRecords ¶ added in v0.1.1
func LoadRecords(records []PostcodeRecord) error
LoadRecords sets the active records and rebuilds internal lookup indexes.
func NewClient ¶ added in v0.2.2
func NewClient(opts ...postcode.ClientOption) (*postcode.Client, error)
NewClient constructs a *postcode.Client wired directly to the in-memory simulator handler. Any additional options (such as WithAPIKey, WithDefaultCache, WithAgentGuard) are applied on top.
func NewHandler ¶
NewHandler constructs an http.Handler that precisely simulates api.postcode.gov.ng.
func NewTransport ¶ added in v0.2.2
func NewTransport() http.RoundTripper
NewTransport returns an in-memory http.RoundTripper that routes requests directly to the simulator handler without opening TCP sockets.
func ResetSimulatedRateLimits ¶
func ResetSimulatedRateLimits()
ResetSimulatedRateLimits clears all recorded transient rate-limit counters in the simulator.
Types ¶
type PostcodeRecord ¶
type PostcodeRecord struct {
Canonical string `json:"canonical"`
StateCode string `json:"state_code"`
StateName string `json:"state_name"`
LGACode string `json:"lga_code"`
LGAName string `json:"lga_name"`
DistrictCode string `json:"district_code"`
DistrictName string `json:"district_name"`
AreaCode string `json:"area_code"`
AreaName string `json:"area_name"`
UnitCode string `json:"unit_code"`
Zone string `json:"zone"`
RecentHouse string `json:"recent_house"`
BuildingUse string `json:"building_use"`
Lat float64 `json:"latitude"`
Lng float64 `json:"longitude"`
}
PostcodeRecord stores test metadata for an official test postcode.
func (*PostcodeRecord) UnmarshalJSON ¶ added in v0.1.1
func (p *PostcodeRecord) UnmarshalJSON(data []byte) error
UnmarshalJSON supports both "latitude"/"longitude" and "lat"/"lng" field names.