Skip to content
This repository has been archived by the owner on Aug 18, 2023. It is now read-only.

Commit

Permalink
first step to move API endpoints to /api/...
Browse files Browse the repository at this point in the history
  • Loading branch information
g0rbe committed May 6, 2023
1 parent 2546fbe commit 329b7b8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
20 changes: 10 additions & 10 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tags:
description: Helper APIs.

paths:
/lookup/{domain}:
/api/lookup/{domain}:
get:
tags:
- domain
Expand All @@ -30,9 +30,9 @@ paths:
Returns a list of subdomains only, the domain not included (eg.: `["one", "two", ...]`).
If a FQDN is requested than the domain name will be taken out and used in the lookup (eg.: `/lookup/columbus.elmasy.com` will be the same as `/lookup/elmasy.com`)
If a FQDN is requested than the domain name will be taken out and used in the lookup (eg.: `/api/lookup/columbus.elmasy.com` will be the same as `/api/lookup/elmasy.com`)
*NOTE*: It is not necessary for the subdomain part to exist in the database, the subdomain part will be trimmed (eg.: `/lookup/totally.invalid.elmasy.com` will be the same as `/lookup/elmasy.com`).
*NOTE*: It is not necessary for the subdomain part to exist in the database, the subdomain part will be trimmed (eg.: `/api/lookup/totally.invalid.elmasy.com` will be the same as `/api/lookup/elmasy.com`).
If `Accept` header is set to `text/plain`, this endpoint returns a newline delimetered text of the list (eg.: `one\ntwo\nthree`).
parameters:
Expand Down Expand Up @@ -84,7 +84,7 @@ paths:
'504':
description: Gateway Timeout. Upstream response takes too long.

/tld/{domain}:
/api/tld/{domain}:
get:
tags:
- domain
Expand All @@ -96,7 +96,7 @@ paths:
The `domain` parameter must be only the Second Level Domain (eg.: `example`)
Example: `/tld/example` returns `["com", "org", "net"]`.
Example: `/api/tld/example` returns `["com", "org", "net"]`.
If `Accept` header is set to `text/plain`, this endpoint returns a newline delimetered text of the list (eg.: `com\norg\nnet`).
parameters:
Expand Down Expand Up @@ -148,7 +148,7 @@ paths:
'504':
description: Gateway Timeout. Upstream response takes too long.

/stat:
/api/stat:
get:
tags:
- info
Expand All @@ -170,7 +170,7 @@ paths:
'503':
description: The API is not enabled

/tools/tld/{fqdn}:
/api/tools/tld/{fqdn}:
get:
tags:
- tools
Expand Down Expand Up @@ -222,7 +222,7 @@ paths:
'504':
description: Gateway Timeout. Upstream response takes too long.

/tools/domain/{fqdn}:
/api/tools/domain/{fqdn}:
get:
tags:
- tools
Expand Down Expand Up @@ -271,7 +271,7 @@ paths:
'504':
description: Gateway Timeout. Upstream response takes too long.

/tools/subdomain/{fqdn}:
/api/tools/subdomain/{fqdn}:
get:
tags:
- tools
Expand Down Expand Up @@ -320,7 +320,7 @@ paths:
'504':
description: Gateway Timeout. Upstream response takes too long.

/tools/isvalid/{fqdn}:
/api/tools/isvalid/{fqdn}:
get:
tags:
- tools
Expand Down
12 changes: 12 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,30 @@ func Run() error {
router.NoRoute(NoRouteHandler)

router.GET("/lookup/:domain", LookupGet)
router.GET("/api/lookup/:domain", LookupGet)

router.GET("/tld/:domain", TLDGet)
router.GET("/api/tld/:domain", TLDGet)

// router.PUT("/insert/:domain", InsertPut)

if config.EnableStatAPI {
router.GET("/stat", StatGet)
router.GET("/api/stat", StatGet)

}

router.GET("/tools/tld/:fqdn", ToolsTLDGet)
router.GET("/api/tools/tld/:fqdn", ToolsTLDGet)

router.GET("/tools/domain/:fqdn", ToolsDomainGet)
router.GET("/api/tools/domain/:fqdn", ToolsDomainGet)

router.GET("/tools/subdomain/:fqdn", ToolsSubdomainGet)
router.GET("/api/tools/subdomain/:fqdn", ToolsSubdomainGet)

router.GET("/tools/isvalid/:fqdn", ToolsIsValidGet)
router.GET("/api/tools/isvalid/:fqdn", ToolsIsValidGet)

srv := &http.Server{
Addr: config.Address,
Expand Down

0 comments on commit 329b7b8

Please sign in to comment.