{"record":{"id":"a2b9ff1de8b89d09","repo":"leptos-rs/leptos","slug":"unsupported-server-function-http-method-method","errorCode":null,"errorMessage":"Unsupported server function HTTP method: {method:?}","messagePattern":"Unsupported server function HTTP method: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"integrations/axum/src/lib.rs","lineNumber":1842,"sourceCode":"\n        // register server functions\n        for (path, method) in server_fn::axum::server_fn_paths() {\n            let cx_with_state = cx_with_state.clone();\n            let handler = move |req: Request<Body>| async move {\n                handle_server_fns_with_context(cx_with_state, req).await\n            };\n\n            if !excluded.contains(path) {\n                router = router.route(\n                    path,\n                    match method {\n                        Method::GET => get(handler),\n                        Method::POST => post(handler),\n                        Method::PUT => put(handler),\n                        Method::DELETE => delete(handler),\n                        Method::PATCH => patch(handler),\n                        _ => {\n                            panic!(\n                                \"Unsupported server function HTTP method: \\\n                                 {method:?}\"\n                            );\n                        }\n                    },\n                );\n            }\n        }\n\n        // register router paths\n        for listing in paths.iter().filter(|p| !p.exclude) {\n            let path = listing.path();\n\n            for method in listing.methods() {\n                let cx_with_state = cx_with_state.clone();\n                let cx_with_state_and_method = move || {\n                    provide_context(method);\n                    cx_with_state();","sourceCodeStart":1824,"sourceCodeEnd":1860,"githubUrl":"https://github.com/leptos-rs/leptos/blob/32d20f6c9d517451d77beb68d88c7716823dac41/integrations/axum/src/lib.rs#L1824-L1860","documentation":"leptos's Axum integration builds a route for each server function based on the HTTP method stored in the server function's metadata. Only GET, POST, PUT, DELETE, and PATCH are mapped to Axum's method routers; any other method causes an immediate panic while constructing the router.","triggerScenarios":"Calling LeptosRoutes::leptos_routes/leptos_routes_with_context on an Axum router when a registered server function declares an HTTP method outside the supported set (e.g. via custom #[server] macro configuration setting method to HEAD or OPTIONS).","commonSituations":"Customizing server function methods with non-standard verbs; hand-written or generated server function registrations with typos in the method; using a macro or codegen that emits methods Axum routing helpers here don't cover.","solutions":["Change the server function to use GET, POST, PUT, DELETE, or PATCH (the default is POST).","If a custom method is truly required, add a match arm mapping it to the corresponding Axum method-router helper before the catch-all panic.","Verify the config passed to #[server(...)] (e.g. `method = ...`) only uses supported verbs."],"exampleFix":"// before\n#[server(FetchThing, \"/api\")]\n#[cfg_attr(feature = \"ssr\", server(method = HEAD))]\nasync fn fetch_thing() -> Result<(), ServerFnError> { ... }\n// after\n#[server(FetchThing, \"/api\")]\n#[cfg_attr(feature = \"ssr\", server(method = GET))]\nasync fn fetch_thing() -> Result<(), ServerFnError> { ... }","handlingStrategy":"validation","validationCode":"const SUPPORTED: &[&str] = &[\"GET\", \"POST\", \"PUT\", \"DELETE\", \"PATCH\"];\nfn server_fn_method_supported(method: &str) -> bool {\n    SUPPORTED.contains(&method.to_uppercase().as_str())\n}","typeGuard":"fn is_supported_method(m: &http::Method) -> bool {\n    matches!(m, &http::Method::GET | &http::Method::POST | &http::Method::PUT | &http::Method::DELETE | &http::Method::PATCH)\n}","tryCatchPattern":null,"preventionTips":["Stick to the default POST method or the five supported verbs in #[server] config.","Review generated server-function registrations in CI for non-standard methods.","Add a build-time test that leptos_routes() constructs without panicking for all registered functions."],"tags":["rust","axum","server-functions","routing","panic"],"backgroundTag":"unsupported-http-method","analyzedSha":"32d20f6c9d517451d77beb68d88c7716823dac41","analyzedAt":"2026-09-01T18:55:42.580Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}