ServerSelector
Domain · API DocAPI sunucu listesini gösterir. Aktif sunucu URL ve ortam etiketi ile öne çıkar, diğerleri details/summary ile listelenir.
https://api.commerce.io/v2
Production
<%- include('modules/domain/api-doc/ServerSelector', {
servers: [
{ serverId: 'srv-prod', url: 'https://api.commerce.io/v2', description: 'Production', environment: 'production' },
{ serverId: 'srv-stg', url: 'https://staging-api.commerce.io/v2', description: 'Staging', environment: 'staging' },
]
}) %>
<%
var _servers = locals.servers || [];
var _value = locals.value || (_servers[0] && _servers[0].serverId) || '';
var _onChange = locals.onChange || null;
if (!_servers.length) { return; }
var envVariant = {
production: 'bg-success-subtle text-success-fg',
staging: 'bg-warning-subtle text-warning-fg',
development: 'bg-info-subtle text-info-fg',
sandbox: 'bg-surface-overlay text-text-secondary',
};
var active = _servers.find(function(s) { return s.serverId === _value; }) || _servers[0];
%>
<%= active.url %>
<% if (active.description) { %>
<%= active.description %>
<% } %>
<% if (active.environment) { %>
<% } %>
<% if (_servers.length > 1) { %>
All servers
<% _servers.forEach(function(server) { %>
<% }); %>
<% } %>