package com.cristobalbernal.foro.controlador;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.net.MalformedURLException;

@Controller
public class Controlador {
    @GetMapping({"/entrar/{usuario}", "/entrar", "/usuario/{usuario}", "/usuario"})
    public String login(@PathVariable(name = "usuario", required = false) String usuario,
                        Model model) throws MalformedURLException {
        model.addAttribute("titulo", "Panel de control");
        model.addAttribute("usuario", usuario);
        return "admin/login";
    }

    @GetMapping("/home")
    public String indice(){
        return "index";
    }

    @GetMapping("/registrar")
    public String registrar(){
        return "Registrar/registrar";
    }
    @GetMapping("/crearPregunta")
    public String pregunta(){
        return "Ask_Question/ask_question";
    }


}

