()
| 199 | } |
| 200 | |
| 201 | func (s *Server) registerDomains() { |
| 202 | huma.Register(s.API, huma.Operation{ |
| 203 | OperationID: "listDomains", Method: http.MethodGet, Path: "/v1/domains", |
| 204 | Summary: "List domains", Tags: []string{"domains"}, |
| 205 | Security: []map[string][]string{{"bearer": {}}}, |
| 206 | }, s.handleListDomains) |
| 207 | |
| 208 | huma.Register(s.API, huma.Operation{ |
| 209 | OperationID: "getDomain", Method: http.MethodGet, Path: "/v1/domains/{domain}", |
| 210 | Summary: "Get a domain", Tags: []string{"domains"}, |
| 211 | Security: []map[string][]string{{"bearer": {}}}, |
| 212 | }, s.handleGetDomain) |
| 213 | |
| 214 | huma.Register(s.API, huma.Operation{ |
| 215 | OperationID: "registerDomain", Method: http.MethodPost, Path: "/v1/domains", |
| 216 | Summary: "Register a domain", Tags: []string{"domains"}, |
| 217 | Security: []map[string][]string{{"bearer": {}}}, DefaultStatus: http.StatusCreated, |
| 218 | Responses: map[string]*huma.Response{ |
| 219 | "409": s.jsonResponse(reflect.TypeOf(ErrorEnvelope{}), "ErrorEnvelope", |
| 220 | "Conflict — the domain is already claimed by another account (code domain_taken)."), |
| 221 | "default": s.errorEnvelopeResponse(), |
| 222 | }, |
| 223 | }, s.handleRegisterDomain) |
| 224 | |
| 225 | huma.Register(s.API, huma.Operation{ |
| 226 | OperationID: "deleteDomain", Method: http.MethodDelete, Path: "/v1/domains/{domain}", |
| 227 | Summary: "Delete a domain", Tags: []string{"domains"}, |
| 228 | Security: []map[string][]string{{"bearer": {}}}, DefaultStatus: http.StatusNoContent, |
| 229 | }, s.handleDeleteDomain) |
| 230 | |
| 231 | huma.Register(s.API, huma.Operation{ |
| 232 | OperationID: "verifyDomain", Method: http.MethodPost, Path: "/v1/domains/{domain}/verify", |
| 233 | Summary: "Verify a domain", Tags: []string{"domains"}, |
| 234 | Description: "Probe the domain's published DNS and, when the verification TXT is present, mark it verified. Returns the per-record diagnostic; a missing TXT yields 412.", |
| 235 | Security: []map[string][]string{{"bearer": {}}}, |
| 236 | Responses: map[string]*huma.Response{ |
| 237 | "412": s.jsonResponse(reflect.TypeOf(VerifyDomainView{}), "VerifyDomainView", |
| 238 | "Precondition Failed — the verification TXT record is not yet published."), |
| 239 | "default": s.errorEnvelopeResponse(), |
| 240 | }, |
| 241 | }, s.handleVerifyDomain) |
| 242 | } |
| 243 | |
| 244 | // verifyDomainOutput uses Huma's special Status field to switch between 200 |
| 245 | // (verified / already-verified) and 412 (TXT not yet published). |
no test coverage detected