Skip to content

Commit

Permalink
rename proxy endpoint to resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
asim committed Jul 21, 2022
1 parent 3553b88 commit ffc0d84
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 66 deletions.
2 changes: 1 addition & 1 deletion url/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"shortURL": "https://m3o.one/u/f8f3f83f3f83g"
}
}],
"proxy": [{
"resolve": [{
"title": "Resolve a short URL to a long destination URL",
"run_check": false,
"request": {
Expand Down
4 changes: 2 additions & 2 deletions url/handler/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (e *Url) List(ctx context.Context, req *url.ListRequest, rsp *url.ListRespo
return nil
}

func (e *Url) Proxy(ctx context.Context, req *url.ProxyRequest, rsp *url.ProxyResponse) error {
func (e *Url) Resolve(ctx context.Context, req *url.ResolveRequest, rsp *url.ResolveResponse) error {
id := strings.Replace(req.ShortURL, e.hostPrefix, "", -1)

records, err := store.Read("url/" + id)
Expand All @@ -205,7 +205,7 @@ func (e *Url) Proxy(ctx context.Context, req *url.ProxyRequest, rsp *url.ProxyRe
}

if len(records) == 0 {
return errors.NotFound("url.proxy", "not found")
return errors.NotFound("url.resolve", "not found")
}

uri := new(url.URLPair)
Expand Down
103 changes: 52 additions & 51 deletions url/proto/url.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions url/proto/url.pb.micro.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions url/proto/url.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ option go_package = "./proto;url";
service Url {
rpc Shorten(ShortenRequest) returns (ShortenResponse) {}
rpc List(ListRequest) returns (ListResponse) {}
rpc Proxy(ProxyRequest) returns (ProxyResponse) {}
rpc Resolve(ResolveRequest) returns (ResolveResponse) {}
rpc Update(UpdateRequest) returns (UpdateResponse) {}
rpc Delete(DeleteRequest) returns (DeleteResponse) {}
}
Expand Down Expand Up @@ -62,13 +62,13 @@ message UpdateRequest {

message UpdateResponse {}

// Proxy returns the destination URL of a short URL.
message ProxyRequest {
// Resolve returns the destination URL of a short URL.
message ResolveRequest {
// short url ID, without the domain, eg. if your short URL is
// `m3o.one/u/someshorturlid` then pass in `someshorturlid`
string shortURL = 1;
}

message ProxyResponse {
message ResolveResponse {
string destinationURL = 1;
}

0 comments on commit ffc0d84

Please sign in to comment.