MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / handleRegisterDomain

Method handleRegisterDomain

internal/httpapi/domains.go:349–380  ·  view source on GitHub ↗
(ctx context.Context, in *registerDomainInput)

Source from the content-addressed store, hash-verified

347}
348
349func (s *Server) handleRegisterDomain(ctx context.Context, in *registerDomainInput) (*domainCreateOutput, error) {
350 user, err := s.requireAccountUser(ctx)
351 if err != nil {
352 return nil, err
353 }
354 normalized, err := agent.ValidateDomain(in.Body.Domain)
355 if err != nil {
356 return nil, NewError(http.StatusBadRequest, "invalid_domain", err.Error())
357 }
358 if s.deps.SharedDomain != "" && strings.EqualFold(normalized, s.deps.SharedDomain) {
359 return nil, NewError(http.StatusBadRequest, "reserved_domain", "reserved domain")
360 }
361 if s.deps.EnforceDomainCreate != nil {
362 if err := s.deps.EnforceDomainCreate(ctx, user.ID); err != nil {
363 if env, ok := limitEnvelope(err); ok {
364 return nil, env
365 }
366 return nil, NewError(http.StatusInternalServerError, "internal_error", "limits check failed")
367 }
368 }
369 d, err := s.deps.ClaimDomain(ctx, normalized, user.ID)
370 if err != nil {
371 if errors.Is(err, identity.ErrDomainTaken) {
372 return nil, NewError(http.StatusConflict, "domain_taken", "domain is already claimed by another account")
373 }
374 return nil, NewError(http.StatusBadRequest, "domain_unavailable", "failed to register domain")
375 }
376 if d == nil {
377 return nil, NewError(http.StatusBadRequest, "domain_unavailable", "failed to register domain")
378 }
379 return &domainCreateOutput{Body: s.domainView(d)}, nil
380}
381
382type deleteDomainOutput struct{}
383

Callers

nothing calls this directly

Calls 6

requireAccountUserMethod · 0.95
domainViewMethod · 0.95
ValidateDomainFunction · 0.92
NewErrorFunction · 0.85
limitEnvelopeFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected