openapi_nexus/generators/go/http/
runtime.rs1use crate::codegen::traits::file_writer::FileInfo;
9
10const CLIENT_GO: &str = include_str!("runtime/client.go.txt");
11const AUTH_GO: &str = include_str!("runtime/auth.go.txt");
12const ERRORS_GO: &str = include_str!("runtime/errors.go.txt");
13const UPLOAD_FILE_GO: &str = include_str!("runtime/upload_file.go.txt");
14
15pub fn runtime_files(header: &str, include_upload_file: bool) -> Vec<FileInfo> {
19 let mut files = vec![
20 FileInfo::runtime("client.go".to_string(), with_header(header, CLIENT_GO)),
21 FileInfo::runtime("auth.go".to_string(), with_header(header, AUTH_GO)),
22 FileInfo::runtime("errors.go".to_string(), with_header(header, ERRORS_GO)),
23 ];
24 if include_upload_file {
25 files.push(FileInfo::runtime(
26 "upload_file.go".to_string(),
27 with_header(header, UPLOAD_FILE_GO),
28 ));
29 }
30 files
31}
32
33fn with_header(header: &str, body: &str) -> String {
34 let mut out = String::with_capacity(header.len() + body.len());
35 out.push_str(header);
36 out.push_str(body);
37 out
38}