It is An URL shortener.
BUT STILL DEVELOPED IN PROGRESS. Please go back here to see the changes later.
- Create your shortened URL.
curl --location --request POST 'https://s.xcc.tw/api/url' \
--header 'Content-Type: application/json' \
--data-raw '{
"originUrl": "https://www.dcard.tw/f/mood/p/238545781?cid=306EA5A4-D67F-41A8-903F-1456E8FDE547",
"expireAt": "2034-11-12T11:45:26.371Z"
}'
- Then use it
# Go to this URL.
https://s.xcc.tw/s/v5oSt3VFD1l
- Add redis. (In progress...)
- Add openAPI3 doc.
- Add k8s yaml.
- Add LB, Grafana, ArgoCD
- Consider not use base62 (KGS, or else...??)
- Add tests.
- cronjob (maybe)
- Ensure using go 1.19.
# go version go1.19
go version
- install dependencies.
go install github.com/silenceper/gowatch@latest
If you want to re-generate the gRPC files, please install these
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest \
&& go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest \
&& go install entgo.io/contrib/entproto/cmd/protoc-gen-entgrpc@latest
And do this:
go generate ./...
- start a MySQL DB.
# For example, use docker
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=sxcctw -d mysql
- start
sxcctw db
server.
./scripts/watchgo.sh sxcctw_db
- start
sxcctw api
server.
./scripts/watchgo.sh sxcctw_api
(openAPI doc TBD)
# Create a shortened id, which is from `https://ntut/club`,
# and set expire time at `2034-11-12T11:45:26.371Z`.
curl --location --request POST 'localhost:8080/api/url' \
--header 'Content-Type: application/json' \
--data-raw '{
"originUrl": "https://ntut/club",
"expireAt": "2034-11-12T11:45:26.371Z"
}'
# Get an existing shortened id (ZNkw23qpiss).
curl --location --request GET 'localhost:8080/api/url?id=ZNkw23qpiss'
- MySQL
- Gin
- Gorm
- gRPC
- Clean Architecture