Skip to content

AquilesBurlamaqui/introGrails

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 

Repository files navigation

Introdução ao Grails

Bem vindos a minha página tutorial sobre Grails.

Grails.

Instalação via windows

Criando API Rest

grails create-app divulga --profile=rest-api

cd divulga

grails

create-domain-class Espaco

Espaco.groovy
package divulga

class Espaco {
	String nome
	String descricao

    static constraints = {
    }
}
Criando os controllers

generate-controller divulga.Espaco

executando a aplicaço

run-app

testando a api rest
listando todos os espaços
curl -i -H "Accept: application/json" localhost:8080/espaco
cadastrando espaço
curl -X POST localhost:8080/espaco  -H "Content-Type: application/json" -d "{\"nome\":\"camisa\",\"descricao\":\"camisa do trabalho\"}"

Instalando o Spring Security

build.gradle

dependencies { ... compile 'org.grails.plugins:spring-security-core:3.2.3' ...

executando o script para criar usuario(User) e os papeis(Role)

grails s2-quickstart divulga User Role

Bootstrap.groovy - criando usuarios iniciais
package divulga

class BootStrap {

    def init = { servletContext ->
    	def role1 = new Role(authority:"ROLE_ADMIN").save flush:true
        def user1 = new User(username:"admin",password:"admin").save flush:true
    	UserRole.create(user1,role1)

    	def role2 = new Role(authority:"ROLE_USER").save flush:true
		def user2 = new User(username:"user",password:"user").save flush:true
		UserRole.create(user2,role2)
    }
    def destroy = {
    }
}

Instalando o Spring Security Rest

compile "org.grails.plugins:spring-security-rest:2.0.0.RC1"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published