From 329b7b89a4afab97c51346fc0ae6d3ff1364a8b4 Mon Sep 17 00:00:00 2001 From: g0rbe Date: Sat, 6 May 2023 11:21:14 +0200 Subject: [PATCH] first step to move API endpoints to /api/... --- openapi.yaml | 20 ++++++++++---------- server/server.go | 12 ++++++++++++ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 4df1c92..7a6281c 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -20,7 +20,7 @@ tags: description: Helper APIs. paths: - /lookup/{domain}: + /api/lookup/{domain}: get: tags: - domain @@ -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: @@ -84,7 +84,7 @@ paths: '504': description: Gateway Timeout. Upstream response takes too long. - /tld/{domain}: + /api/tld/{domain}: get: tags: - domain @@ -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: @@ -148,7 +148,7 @@ paths: '504': description: Gateway Timeout. Upstream response takes too long. - /stat: + /api/stat: get: tags: - info @@ -170,7 +170,7 @@ paths: '503': description: The API is not enabled - /tools/tld/{fqdn}: + /api/tools/tld/{fqdn}: get: tags: - tools @@ -222,7 +222,7 @@ paths: '504': description: Gateway Timeout. Upstream response takes too long. - /tools/domain/{fqdn}: + /api/tools/domain/{fqdn}: get: tags: - tools @@ -271,7 +271,7 @@ paths: '504': description: Gateway Timeout. Upstream response takes too long. - /tools/subdomain/{fqdn}: + /api/tools/subdomain/{fqdn}: get: tags: - tools @@ -320,7 +320,7 @@ paths: '504': description: Gateway Timeout. Upstream response takes too long. - /tools/isvalid/{fqdn}: + /api/tools/isvalid/{fqdn}: get: tags: - tools diff --git a/server/server.go b/server/server.go index 1aee003..b2e7833 100644 --- a/server/server.go +++ b/server/server.go @@ -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,