Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › std/ › http/ › Client.zig › createProxyFromEnvVar
createProxyFromEnvVar
Client.createProxyFromEnvVar
fn createProxyFromEnvVar (
arena : Allocator ,
environ_map : *const std .process .Environ .Map ,
env_var_names : []const []const u8 ,
) !?*Proxy
File
Code
fn createProxyFromEnvVar (
arena : Allocator ,
environ_map : *const std .process .Environ .Map ,
env_var_names : []const []const u8 ,
) !?*Proxy {
const content = for (env_var_names ) |name | {
const content = environ_map .get (name ) orelse continue ;
if (content .len == 0 ) continue ;
break content ;
} else return null ;
const uri = Uri .parse (content ) catch try Uri .parseAfterScheme ("http" , content );
const protocol = Protocol .fromUri (uri ) orelse return null ;
var host_buf : [HostName .max_len ]u8 = undefined ;
const raw_host = try HostName .fromUri (uri , &host_buf );
const authorization : ?[]const u8 = if (uri .user != null or uri .password != null ) a : {
const authorization = try arena .alloc (u8 , basic_authorization .valueLengthFromUri (uri ));
assert (basic_authorization .value (uri , authorization ).len == authorization .len );
break :a authorization ;
} else null ;
const proxy = try arena .create (Proxy );
proxy .* = .{
.protocol = protocol ,
.host = .{ .bytes = try arena .dupe (u8 , raw_host .bytes ) },
.authorization = authorization ,
.port = uriPort (uri , protocol ),
.supports_connect = true ,
};
return proxy ;
}