-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a6acde
commit 10319cf
Showing
5 changed files
with
31 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Esta é uma pagina de exemplo. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Aqui está um exemplo funcional completo de um servidor web simples: | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
) | ||
|
||
// A função handler é do tipo http.HandlerFunc. Leva um http.ResponseWriter e um http.Request | ||
// como seus argumentos. | ||
|
||
// Um valor http.ResponseWriter monta a resposta do servidor HTTP; ao escrever nele enviamos dados | ||
// para o cliente HTTP. Nesse caso enviei "Olá, eu adoro %s!" | ||
|
||
// Um http.Request é uma estrutura de dados que representa a solicitação HTTP do client. | ||
// O r.URL.Path é o componente do caminho do URL da solicitação. O [1:] significa | ||
// "criar um sub-slice do Path do primeiro caractere até o fim." | ||
// Isso remove o "/" inicial do nome do caminho. | ||
|
||
// Então qualquer coisa escrita no browser depois da raiz / é adicionado a mensagem de "Olá, eu adoro..." | ||
|
||
func handler(w http.ResponseWriter, r *http.Request) { | ||
fmt.Fprintf(w, "Olá, eu adoro %s!", r.URL.Path[1:]) | ||
} | ||
|
||
func main() { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters