ocre-cli 0.2.0

Command-line tool for Ocre: create, generate, migrate, run and deploy apps.
//! <%= human %> JSON API. Generated by `<%= command %>`.
//!
<% for action in actions %>
//! GET <%= action.path %>
<% endfor %>

use axum::{Router, routing::get};
use ocre::{ApiResult, Ctx, Json};
use serde::Serialize;
<% if auth %>

use crate::auth_api::BearerUser;
<% endif %>

pub fn routes() -> Router<Ctx> {
    Router::new()
<% for action in actions %>
        .route("<%= action.path %>", get(<%= action.name %>))
<% endfor %>
}
<% for action in actions %>

/// Body of `GET <%= action.path %>`.
#[derive(Serialize)]
struct <%= action.pascal %>Response {
    message: &'static str,
}

<% if auth %>
/// Needs `Authorization: Bearer <JWT or API key>`; 401 otherwise.
async fn <%= action.name %>(BearerUser(_user): BearerUser) -> ApiResult<Json<<%= action.pascal %>Response>> {
<% else %>
async fn <%= action.name %>() -> ApiResult<Json<<%= action.pascal %>Response>> {
<% endif %>
    Ok(Json(<%= action.pascal %>Response { message: "Edit <%= action.name %> in src/<%= file %>.rs" }))
}
<% endfor %>