context api

type UserId = String where NonEmpty

type View = { ok: Bool }

-- A Bearer actor whose identity this service verifies but does not capture.
actor User { auth = Bearer(secret = "AUTH_JWT_SECRET"), identity = UserId }

service api from http {
  -- Anonymous: declare + verify the contract, capture nothing.
  on GET("/ping") by Visitor () -> Effect[HttpResult[View]] {
    Ok(View { ok: true })
  }

  -- Authenticated gate: the token is verified fail-closed, identity discarded.
  on GET("/healthz") by User () -> Effect[HttpResult[View]] {
    Ok(View { ok: true })
  }
}
