Skip to content
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

Rewrite App #67

Merged
merged 8 commits into from
Mar 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 60 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,71 @@
# Simple HTTP API convert longitude&latitude to timezone name

> **Note**: It's designed as a debugger tool for package
> [tzf](https://github.com/ringsaturn/tzf), not production ready.

```bash
go install github.com/ringsaturn/tzf-server@latest

# check args
tzf-server --help

# start server
tzf-server
# start general server
./tzf-server

# start FuzzyFinder based server
./tzf-server -type 1
```

## Web Pages

### All supported timezone names

[`http://localhost:8080/tzs/list/page`](http://localhost:8080/tzs/list/page)

## API

### Lookup Location's timezone

```bash
curl "http://localhost:8080/tz?lng=116.3883&lat=39.9289"
```

Output:

```json
{
"timezone": "Asia/Shanghai"
}
```

Example links:
### Lookup Location's timezones

- Query by location [`http://localhost:8080/tz?lng=-0.1276&lat=51.5073`](http://localhost:8080/tz?lng=-0.1276&lat=51.5073)
- Query by offset [`http://localhost:8080/tz/offset?offset=0`](http://localhost:8080/tz/offset?offset=0)
- Query by name [`http://localhost:8080/info?name=Etc/GMT-12`](http://localhost:8080/info?name=Etc/GMT-12)
```bash
curl "http://localhost:8080/tzs?lng=87.6168&lat=43.8254"
```

Output:

```json
{
"timezones": ["Asia/Shanghai", "Asia/Urumqi"]
}
```

### All supported timezone names

```bash
curl "http://localhost:8080/tzs/list"
```

Output:

```json
{
"timezones": [
"Africa/Abidjan",
// ...
"Pacific/Tongatapu"
]
}
```
12 changes: 7 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ module github.com/ringsaturn/tzf-server
go 1.19

require (
github.com/gin-contrib/cors v1.4.0
github.com/gin-gonic/gin v1.9.0
github.com/ringsaturn/tzf v0.11.0
github.com/paulmach/orb v0.9.0
github.com/ringsaturn/tzf v0.11.2
github.com/ringsaturn/tzf-rel v0.0.2022-g1
google.golang.org/protobuf v1.28.1
google.golang.org/protobuf v1.30.0
)

require (
Expand All @@ -17,24 +19,24 @@ require (
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.11.2 // indirect
github.com/goccy/go-json v0.10.0 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/paulmach/orb v0.8.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/tidwall/geoindex v1.7.0 // indirect
github.com/tidwall/geojson v1.4.3 // indirect
github.com/tidwall/rtree v1.9.4 // indirect
github.com/tidwall/rtree v1.10.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/twpayne/go-polyline v1.1.1 // indirect
github.com/ugorji/go/codec v1.2.9 // indirect
go.mongodb.org/mongo-driver v1.11.1 // indirect
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/exp v0.0.0-20221031165847-c99f073a8326 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
Expand Down
74 changes: 64 additions & 10 deletions go.sum

Large diffs are not rendered by default.

Loading