TungNT (Blue)

tungnt.blue@gmail.com

User Tools

Site Tools


development:goravel

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
development:goravel [2024/11/27 14:17] – [Cơ bản] tungntdevelopment:goravel [2024/11/28 05:04] (current) – [Middleware] tungnt
Line 1: Line 1:
-====== Cài đặt ======+====== Install ======
  
 https://www.goravel.dev/getting-started/installation.html https://www.goravel.dev/getting-started/installation.html
Line 91: Line 91:
  
 <code> <code>
-[program:goravel.example.com]+[program:goravel]
 process_name=%(program_name)s_%(process_num)02d process_name=%(program_name)s_%(process_num)02d
-command=go run /private/var/www/examples/goravel.example.com/main.go+;command=/usr/local/go/bin/go run /private/var/www/examples/goravel.example.com/main.go 
 +command=/Users/tungnt/go/bin/air -c /private/var/www/examples/goravel.example.com/.air.toml
 directory=/private/var/www/examples/goravel.example.com directory=/private/var/www/examples/goravel.example.com
 autostart=true autostart=true
Line 99: Line 100:
 user=tungnt user=tungnt
 redirect_stderr=true redirect_stderr=true
-stdout_logfile=/private/var/www/examples/goravel.example.com/storage/logs/goravel.example.com.log+stdout_logfile=/private/var/www/examples/goravel.example.com/storage/logs/horizon.log
 stopwaitsecs=3600 stopwaitsecs=3600
 </code> </code>
Line 143: Line 144:
 ===== Controllers ===== ===== Controllers =====
  
 +<code>
 +go run . artisan make:controller test/ExampleController
 +
 +go run . artisan make:controller --resource PhotoController
 +</code>
 +
 +===== Middleware =====
 +
 +<code go>
 +go run . artisan make:middleware ApiAuth
 +</code>
 +
 +<file go app/http/kernel.go>
 +package http
 +
 +import (
 + "github.com/goravel/framework/contracts/http"
 +
 + "goravel/app/http/middleware"
 +)
 +
 +type Kernel struct {
 +}
 +
 +// The application's global HTTP middleware stack.
 +// These middleware are run during every request to your application.
 +func (kernel Kernel) Middleware() []http.Middleware {
 + return []http.Middleware{
 + middleware.ApiAuth(),
 + }
 +}
 +</file>
 +
 +<file go routes/api.go>
 +import "github.com/goravel/framework/http/middleware"
 +
 +facades.Route().Middleware(middleware.Auth()).Get("users", userController.Show)
 +</file>
 +
 +===== Request =====
 +
 +<code>
 +go run . artisan make:request test/ExamplePostRequest
 +</code>
 +
 +===== Rule =====
 +
 +<code>
 +go run . artisan make:rule Uppercase
 +</code>
development/goravel.1732717021.txt.gz · Last modified: 2024/11/27 14:17 by tungnt

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki