messages
list
category
string
crate
string
source
dict
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I set up a router with multiple routes and add middleware in axum? Show a complete example with a fallback handler." }...
api_usage
axum
{ "type": "function_item", "name": "app", "source_file": "examples/sse/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I return a streaming response from an axum handler using Body::from_stream?" }, { "role": "assistant", "cont...
api_usage
axum
{ "type": "function_item", "name": "stream_some_data", "source_file": "examples/reqwest-response/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I serve HTML templates in axum? I want to return templated responses from a handler." }, { "role": "assistant", ...
code_explanation
axum
{ "type": "function_item", "name": "main", "source_file": "examples/templates/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "I have a custom extractor for checking authorization headers. It works, but it's a bit verbose. How would you clean it up?\n\n`...
refactoring
axum
{ "type": "function_item", "name": "from_request_parts", "source_file": "axum/src/middleware/from_extractor.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Explain how axum handles application state injection in handlers using the State extractor. What patterns enable dependency inj...
code_explanation
axum
{ "type": "function_item", "name": "create_user_dyn", "source_file": "examples/dependency-injection/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "What's wrong with this axum route handler, and how should I fix it?" }, { "role": "assistant", "content": "The bug ...
bug_detection
axum
{ "type": "function_item", "name": "any_service", "source_file": "axum/src/routing/method_routing.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I write middleware in axum that can clone and modify the request state, then pass it through the request handling pipeli...
api_usage
axum
{ "type": "function_item", "name": "clone", "source_file": "axum/src/middleware/map_request.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I set up a basic Axum server that listens on a TCP socket and handles GET requests at the root path?" }, { "role...
api_usage
axum
{ "type": "function_item", "name": "main", "source_file": "examples/auto-reload/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Write a webhook handler that validates HMAC-SHA256 signatures from a request HeaderMap before processing the payload." }, {...
code_generation
axum
{ "type": "function_item", "name": "handler", "source_file": "axum/src/extract/json.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Refactor this query extraction test so it properly validates that a handler correctly deserializes and echoes back query parame...
refactoring
axum
{ "type": "function_item", "name": "check", "source_file": "axum/src/extract/query.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "I'm creating a user handler with a database connection pool and JSON body. Here's my code—why does it fail to compile?\n\n```ru...
bug_detection
axum
{ "type": "function_item", "name": "create_user", "source_file": "examples/diesel-postgres/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Explain how axum's routing works with method-specific handlers. What are the differences between using `get()`, `post()`, `put(...
code_explanation
axum
{ "type": "function_item", "name": "filename_escapes_backslashes", "source_file": "axum-extra/src/response/file_stream.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How does the `Sink` trait implementation for `WebSocket` in axum handle message sending? Explain the purpose of `poll_ready`, `...
code_explanation
axum
{ "type": "impl_item", "name": "WebSocket", "source_file": "axum/src/extract/ws.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Write a test for an axum handler that uses ConnectInfo to extract the client's SocketAddr. The test should verify that the hand...
test_generation
axum
{ "type": "impl_item", "name": "SocketAddr", "source_file": "axum/src/extract/connect_info.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I extract path parameters from a URL in axum and use them in my handler?" }, { "role": "assistant", "content...
api_usage
axum
{ "type": "function_item", "name": "captures_match_empty_inner_segments", "source_file": "axum/src/extract/path/mod.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I build a Server-Sent Events (SSE) endpoint in axum with a keep-alive stream?" }, { "role": "assistant", "co...
code_generation
axum
{ "type": "function_item", "name": "handler", "source_file": "axum/src/response/sse.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Explain how the MatchedPath extractor works in axum routing. How does it capture the matched route pattern, and what extractors...
code_explanation
axum
{ "type": "function_item", "name": "matching_colon", "source_file": "axum/src/extract/matched_path.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Explain how Router::nest() works for creating path-prefixed sub-routers in axum." }, { "role": "assistant", "conten...
code_explanation
axum
{ "type": "function_item", "name": "main", "source_file": "axum/src/routing/mod.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I set up WebSocket handlers in axum? Show me how to use WebSocketUpgrade." }, { "role": "assistant", "conten...
api_usage
axum
{ "type": "function_item", "name": "handler", "source_file": "axum/src/extract/ws.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "I need to create an HTTP endpoint that extracts a user ID from the URL path and handles various extraction errors gracefully. H...
code_generation
axum
{ "type": "function_item", "name": "fmt", "source_file": "axum/src/extract/path/mod.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Refactor this verbose middleware setup into a cleaner approach using Axum's middleware composition. Here's the messy code:\n\na...
refactoring
axum
{ "type": "function_item", "name": "map_response_with_state", "source_file": "axum/src/middleware/map_response.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I serve files with custom headers like Content-Disposition and Content-Type in axum?" }, { "role": "assistant", ...
api_usage
axum
{ "type": "struct_item", "name": "Attachment", "source_file": "axum-extra/src/response/attachment.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "I have a custom extractor that implements FromRequestParts. What's a common bug when the state generic is incorrectly bound, an...
bug_detection
axum
{ "type": "function_item", "name": "from_request_parts", "source_file": "axum/src/extract/state.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust developer familiar with the Axum web framework. Help identify and fix bugs in Axum code." }, { "role": "user", "content": "I have a route that uses Path<(String, u32)> but my URL path is `/users/{name}/{age}`. When I test it, deserialization...
bug_detection
axum
{ "type": "function_item", "name": "str_reference_deserialize", "source_file": "axum/src/extract/path/mod.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "I need to refactor a redirect handler that manually constructs URIs with scheme and authority. Can you show a cleaner approach?...
refactoring
axum
{ "type": "function_item", "name": "redirect_http_to_https", "source_file": "examples/tls-rustls/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "I need to extract custom path parameters with multiple types. How do I deserialize complex path parameter structures in axum?" ...
code_generation
axum
{ "type": "struct_item", "name": "MoreChars", "source_file": "axum/src/extract/path/mod.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Refactor this todo handler that uses inline SQL into a clean layered architecture. Current code mixes database logic with HTTP ...
refactoring
axum
{ "type": "function_item", "name": "main", "source_file": "examples/todos/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I implement a custom FromRequestParts extractor that validates a user ID from headers? Write tests for both valid and in...
test_generation
axum
{ "type": "function_item", "name": "test", "source_file": "examples/versioning/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Explain how to build a basic axum Router that handles HTTP requests and returns responses. What are the core builder methods?" ...
code_explanation
axum
{ "type": "function_item", "name": "native_tls_acceptor", "source_file": "examples/low-level-native-tls/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Write an axum handler that accepts a POST request with a JSON body containing a user's name and email. Extract both the JSON pa...
code_generation
axum
{ "type": "function_item", "name": "clone", "source_file": "axum/src/routing/mod.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Refactor this messy request handler to be cleaner and more idiomatic for axum routing and extractors." }, { "role": "as...
refactoring
axum
{ "type": "function_item", "name": "process_message", "source_file": "examples/websockets/src/client.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "I'm testing nested routers with trailing slash redirection. My test checks that requests without the trailing slash redirect to...
bug_detection
axum
{ "type": "function_item", "name": "tsr_works_in_nested_router", "source_file": "axum-extra/src/routing/mod.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I set up multiple concurrent axum services on different ports?" }, { "role": "assistant", "content": "Create...
code_generation
axum
{ "type": "function_item", "name": "main", "source_file": "examples/cors/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Refactor this messy axum code that serves Server-Sent Events. Currently the code lacks proper error handling and doesn't config...
refactoring
axum
{ "type": "function_item", "name": "keep_alive", "source_file": "axum/src/response/sse.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Create a complete axum application that extracts a UUID from the URL path parameter and handles invalid UUID format with a prop...
code_generation
axum
{ "type": "function_item", "name": "deserialize_error_single_value", "source_file": "axum/src/extract/path/mod.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "I need to build a rate-limiting middleware that tracks requests per IP address and allows 10 requests per minute. How would I i...
code_generation
axum
{ "type": "function_item", "name": "middleware", "source_file": "axum/src/middleware/map_request.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I create an axum handler that uses WebSocket to send messages? What's the pattern for accepting a WebSocket upgrade and ...
code_generation
axum
{ "type": "function_item", "name": "text", "source_file": "axum/src/extract/ws.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I test custom rejection types and error responses in axum extractors?" }, { "role": "assistant", "content": ...
test_generation
axum
{ "type": "impl_item", "name": "Display", "source_file": "axum-extra/src/extract/with_rejection.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I properly structure nested routes in Axum to ensure path validation? Show a complete example that defines a Router with...
code_generation
axum
{ "type": "function_item", "name": "validate_nest_path", "source_file": "axum/src/routing/path_router.rs", "pattern": null }
[ { "role": "system", "content": "You are a Rust web development expert specializing in Axum framework patterns. Generate complete, working code examples with all necessary imports. Focus on practical, real-world usage." }, { "role": "user", "content": "How do I add middleware layers to my Axum ro...
api_usage
axum
{ "type": "unknown", "name": "", "source_file": "axum/src/routing/mod.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do you extract optional query parameters and handle parsing errors in axum?" }, { "role": "assistant", "content...
code_generation
axum
{ "type": "function_item", "name": "optional_query_preserves_parsing_errors", "source_file": "axum-extra/src/extract/query.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Refactor this fallback handler to handle different HTTP methods more clearly:\n\n```rust\nasync fn fallback(method: Method) -> ...
refactoring
axum
{ "type": "function_item", "name": "fallback", "source_file": "axum/src/routing/method_routing.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Generate ONE high-quality axum training pair INSPIRED BY this code chunk.\nFocus on the axum APIs and patterns shown, not the s...
code_explanation
axum
{ "type": "const_item", "name": "_", "source_file": "axum/src/routing/method_routing.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "I have a WebSocket handler that manually checks messages and sends responses with nested match statements. How should I refacto...
refactoring
axum
{ "type": "function_item", "name": "recv", "source_file": "axum/src/extract/ws.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How does the middleware pattern in axum work for inspecting and modifying request/response bodies? Explain the specific APIs an...
code_explanation
axum
{ "type": "function_item", "name": "print_request_response", "source_file": "examples/print-request-response/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I implement a Stream wrapper that converts WebSocket messages in axum? I need to handle the polling loop correctly." }...
code_explanation
axum
{ "type": "function_item", "name": "poll_next", "source_file": "axum/src/extract/ws.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Write an axum handler that accepts form data and returns it as a properly encoded URL-encoded response. The handler should extr...
code_generation
axum
{ "type": "impl_item", "name": "IntoResponse", "source_file": "axum/src/form.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I implement a custom extractor that validates a bearer token from the Authorization header and returns an error if missi...
code_generation
axum
{ "type": "impl_item", "name": "TestExtractor", "source_file": "axum-extra/src/extract/with_rejection.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I return different content types (JSON, HTML, plain text) from different routes in an axum application?" }, { "r...
code_generation
axum
{ "type": "function_item", "name": "handler_home", "source_file": "examples/templates-minijinja/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I use HeaderMap to read request headers in an axum handler? Show an example that extracts and validates multiple headers...
api_usage
axum
{ "type": "function_item", "name": "handler", "source_file": "axum/src/extract/mod.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "I want to understand how stateful routing works in axum. How do `.with_state()` and the `State` extractor work together?" }, ...
code_explanation
axum
{ "type": "function_item", "name": "with_state", "source_file": "axum/src/routing/method_routing.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I handle file uploads in axum using the Multipart extractor?" }, { "role": "assistant", "content": "Use `Mul...
code_generation
axum
{ "type": "function_item", "name": "handler", "source_file": "axum-extra/src/extract/multipart.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I define routes with proper parameter syntax in axum? What's the correct way to capture path segments?" }, { "ro...
code_generation
axum
{ "type": "function_item", "name": "validate_v07_paths", "source_file": "axum/src/routing/path_router.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How can I write a test that verifies a 404 Not Found response when a route doesn't exist in an axum application? Provide a comp...
test_generation
axum
{ "type": "function_item", "name": "not_found", "source_file": "examples/testing/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Write an axum handler that returns a file attachment with a filename that contains special characters, ensuring proper escaping...
code_generation
axum
{ "type": "function_item", "name": "attachment_filename_escapes_quotes", "source_file": "axum-extra/src/response/attachment.rs", "pattern": null }
[ { "role": "system", "content": "You are a Rust web development expert specializing in Axum framework patterns. Generate complete, working code examples with all necessary imports. Focus on practical, real-world usage." }, { "role": "user", "content": "How does Axum's IntoResponse trait work with...
code_explanation
axum
{ "type": "unknown", "name": "", "source_file": "axum/src/response/mod.rs", "pattern": null }
[ { "role": "system", "content": "You are a Rust expert teaching axum web framework patterns." }, { "role": "user", "content": "How do I register multiple HTTP methods on the same route in axum?" }, { "role": "assistant", "content": "In axum, you can use the routing functions to regist...
api_usage
axum
{ "type": "function_item", "name": "method_filter", "source_file": "axum/src/routing/method_routing.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "I have a messy WebSocket echo handler that processes messages in a loop without proper error handling. Refactor it to use clean...
refactoring
axum
{ "type": "impl_item", "name": "WebSocket", "source_file": "axum/src/extract/ws.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Write a unit test that verifies a complex axum router properly handles multiple HTTP methods (GET, POST, PUT) on the same route...
test_generation
axum
{ "type": "function_item", "name": "building_complex_router", "source_file": "axum/src/routing/method_routing.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "What happens if you don't use the body-consuming extractor last in your handler arguments, and how do you fix it?" }, { ...
bug_detection
axum
{ "type": "impl_item", "name": "MethodFilter", "source_file": "axum/src/routing/method_filter.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I handle file uploads with multipart form data in axum? Show a complete working example." }, { "role": "assistan...
api_usage
axum
{ "type": "impl_item", "name": "MultipartError", "source_file": "axum-extra/src/extract/multipart.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Create an axum endpoint that accepts brotli-compressed JSON request bodies and returns a JSON response." }, { "role": "...
code_generation
axum
{ "type": "function_item", "name": "decompress_br_request_bodies", "source_file": "examples/compression/src/tests.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Write unit tests for the Json extractor in axum. Cover valid JSON parsing, invalid JSON bodies, and content-type validation." ...
test_generation
axum
{ "type": "function_item", "name": "test", "source_file": "axum/src/extract/mod.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I implement request timeouts for my axum server? I want to abort slow requests and return an error response." }, { ...
api_usage
axum
{ "type": "function_item", "name": "main", "source_file": "examples/readme/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Explain how to implement a custom extractor in axum using FromRequestParts with custom rejection error types. Show a complete e...
code_explanation
axum
{ "type": "function_item", "name": "handler", "source_file": "axum-extra/src/extract/with_rejection.rs", "pattern": null }
[ { "role": "system", "content": "You are a Rust expert teaching axum web framework patterns for building real-time APIs." }, { "role": "user", "content": "How do I build a real-time Server-Sent Events (SSE) endpoint with keep-alive in axum?" }, { "role": "assistant", "content": "Creat...
code_generation
axum
{ "type": "function_item", "name": "keep_alive", "source_file": "axum/src/response/sse.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "I have a verbose middleware implementation that manually implements the Tower `Service` trait. Can I refactor this to use axum'...
refactoring
axum
{ "type": "impl_item", "name": "Next", "source_file": "axum/src/middleware/from_fn.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I build a router that handles multiple HTTP methods on the same path with different handlers? I want GET and POST on /it...
api_usage
axum
{ "type": "function_item", "name": "clone", "source_file": "axum/src/routing/method_routing.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How does the IntoResponseParts trait work in axum, and why would you implement it for custom types like SignedCookieJar?" }, ...
code_explanation
axum
{ "type": "impl_item", "name": "IntoResponseParts", "source_file": "axum-extra/src/extract/cookie/signed.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Explain how axum's middleware::from_fn() enables composable request/response processing with the Next type." }, { "role...
code_explanation
axum
{ "type": "function_item", "name": "middleware", "source_file": "axum/src/middleware/map_response.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "I'm writing a WebSocket test for my axum app, but I'm worried I might have an issue. Can you spot the bug?\n\n```rust\nasync fn...
bug_detection
axum
{ "type": "function_item", "name": "integration_test", "source_file": "axum/src/extract/ws.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Write tests for a custom axum extractor that implements FromRequestParts. The extractor should extract a value from request par...
test_generation
axum
{ "type": "impl_item", "name": "MyExtractor", "source_file": "axum/src/middleware/from_extractor.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How does axum manage path-to-route mappings internally? Explain the data structures and APIs involved." }, { "role": "a...
code_explanation
axum
{ "type": "function_item", "name": "insert", "source_file": "axum/src/routing/path_router.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I set up a basic axum Router with nested routes, middleware for rate limiting and tracing, and shared application state ...
code_generation
axum
{ "type": "function_item", "name": "main", "source_file": "examples/key-value-store/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How should I write unit tests for typed path routing handlers in axum?" }, { "role": "assistant", "content": "You c...
test_generation
axum
{ "type": "function_item", "name": "typed_patch", "source_file": "axum-extra/src/routing/mod.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Create a complete axum handler that extracts multiple typed path parameters (e.g., two UUIDs from a route like /resources/{res}...
code_generation
axum
{ "type": "function_item", "name": "deserialize_error_multi_value", "source_file": "axum/src/extract/path/mod.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Refactor this concurrent client code to use a cleaner axum pattern. The original uses JoinSet but mixes concerns. Show a better...
refactoring
axum
{ "type": "function_item", "name": "main", "source_file": "examples/websockets/src/client.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I implement a custom extractor with a custom error type that wraps JsonRejection in axum?" }, { "role": "assista...
code_generation
axum
{ "type": "enum_item", "name": "ApiError", "source_file": "examples/customize-extractor-error/src/with_rejection.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How would you set up a WebSocket handler in axum that accepts a connection and echoes messages back to the client? Use proper c...
code_generation
axum
{ "type": "function_item", "name": "unit_test", "source_file": "examples/testing-websockets/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Create an axum application that captures errors in middleware and logs them to standard output. The middleware should inspect t...
code_generation
axum
{ "type": "function_item", "name": "log_app_errors", "source_file": "examples/error-handling/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I build a file download endpoint that returns bytes with a custom Content-Type header?" }, { "role": "assistant"...
code_generation
axum
{ "type": "function_item", "name": "handler", "source_file": "axum/src/response/mod.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I build an OAuth callback handler that extracts the authorization code from query parameters and redirects to a success ...
code_generation
axum
{ "type": "function_item", "name": "callback", "source_file": "examples/oauth/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I stream server-sent events (SSE) from an axum handler and automatically send keep-alive messages while waiting for real...
code_generation
axum
{ "type": "function_item", "name": "keep_alive_ends_when_the_stream_ends", "source_file": "axum/src/response/sse.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Here's a buggy axum handler. Identify the issue and provide the corrected version:\n\n```rust\nasync fn get_user(Json(user_data...
bug_detection
axum
{ "type": "function_item", "name": "handler", "source_file": "axum/src/extract/path/mod.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I implement a custom extractor for axum that validates request parts before extracting them?" }, { "role": "assi...
api_usage
axum
{ "type": "function_item", "name": "from_request_parts", "source_file": "axum/src/middleware/from_extractor.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "I need to build an API that validates path parameters and returns appropriate HTTP status codes based on parsing errors. If a p...
code_generation
axum
{ "type": "function_item", "name": "status", "source_file": "axum/src/extract/path/mod.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How does axum handle multipart upload errors? Explain the pattern for mapping multer errors to appropriate HTTP status codes, a...
code_explanation
axum
{ "type": "function_item", "name": "status_code_from_multer_error", "source_file": "axum/src/extract/multipart.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do MethodFilter and the error display work in axum's routing system? Explain the specific axum APIs involved." }, { ...
code_explanation
axum
{ "type": "impl_item", "name": "NoMatchingMethodFilter", "source_file": "axum/src/routing/method_filter.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Explain how the .layer() method works on a Router. How does it apply middleware to routes?" }, { "role": "assistant", ...
code_explanation
axum
{ "type": "function_item", "name": "main", "source_file": "axum/src/routing/mod.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I build a basic REST API with axum? Show me handlers, routing, State management, and how to serve it." }, { "rol...
api_usage
axum
{ "type": "function_item", "name": "main", "source_file": "examples/readme/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Write complete tests for the Path extractor's byte deserialization functionality in axum." }, { "role": "assistant", ...
test_generation
axum
{ "type": "function_item", "name": "deserialize_bytes", "source_file": "axum/src/extract/path/de.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "I need to create a custom extractor for my axum router that retrieves custom data from request extensions. How can I implement ...
code_generation
axum
{ "type": "function_item", "name": "from_request_parts", "source_file": "axum/src/extract/matched_path.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I connect axum to a database using a connection pool?" }, { "role": "assistant", "content": "You can share a...
api_usage
axum
{ "type": "function_item", "name": "main", "source_file": "examples/diesel-postgres/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Write a test that verifies a simple GET handler responds with the correct status code and body. Use real axum test utilities an...
test_generation
axum
{ "type": "function_item", "name": "server", "source_file": "examples/reverse-proxy/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Explain how this handler extracts a Request, validates it, and returns an IntoResponse. What are the key axum APIs used?" }, ...
code_explanation
axum
{ "type": "function_item", "name": "proxy", "source_file": "examples/http-proxy/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "What is the bug in this redirect handler code and how should it be fixed?\n\nuse axum::response::Redirect;\nuse axum::http::Sta...
bug_detection
axum
{ "type": "function_item", "name": "correct_status", "source_file": "axum/src/response/redirect.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "Explain how axum::serve() starts the server and handles incoming connections." }, { "role": "assistant", "content":...
code_explanation
axum
{ "type": "function_item", "name": "main", "source_file": "examples/compression/src/main.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "I want to build a response transformation middleware that modifies responses after handlers execute. How do I extract state and...
code_generation
axum
{ "type": "macro_definition", "name": "impl_service", "source_file": "axum/src/middleware/map_response.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "What's the bug in this handler that tries to set a content-disposition header for file downloads? The code compiles but has a s...
bug_detection
axum
{ "type": "impl_item", "name": "IntoResponse", "source_file": "axum-extra/src/response/attachment.rs", "pattern": null }
[ { "role": "system", "content": "You are an expert Rust programmer specializing in the axum crate and modern Rust development patterns." }, { "role": "user", "content": "How do I set up a basic axum router with multiple routes? Show a minimal working example with GET and POST endpoints." }, {...
code_generation
axum
{ "type": "function_item", "name": "default", "source_file": "axum/src/routing/path_router.rs", "pattern": null }