fix golang code http method

I'm trying to figure out the best way to handle requests to / and only / in Go and handle different methods in different ways. Here's the best I've come up with:

package main

import (






func main() {

[login to view URL]("/", func(w [login to view URL], r *[login to view URL]) {

if [login to view URL] != "/" {

[login to view URL](w, r)



if [login to view URL] == "GET" {

[login to view URL](w, "GET, %q", [login to view URL]([login to view URL]))

} else if [login to view URL] == "POST" {

[login to view URL](w, "POST, %q", [login to view URL]([login to view URL]))

} else {

[login to view URL](w, "Invalid request method.", 405)



[login to view URL]([login to view URL](":8080", nil))


Is this idiomatic Go? Is this the best I can do with the standard http lib? I'd much rather do something like [login to view URL]("/", handler) as in express or Sinatra. Is there a good framework for writing simple REST services? [login to view URL] looks attractive but appears stagnant.

Thank you for your advice.

Kemahiran: Golang, HTML, Javascript, PHP, Python

Lihat lagi: fix html code, fix perl code, keylogger source code http post, golang fasthttp example, golang http server post example, golang http request body, fasthttp vs net/http, golang http client timeout, golang http client, golang http post json, golang http redirect, fix banner code, fix php code, java code simplex method, check fix webpage code, clipshare cpaint error invalid http response code, form fix page code php html, html fix php code, source code http proxy server, cpaint error invalid http response code

Tentang Majikan:
( 15 ulasan ) Pyeongtaeksi Gyeonggi-do, Korea, Republic of

ID Projek: #17557110

Dianugerahkan kepada:


Hi there .. you know what to do .. this is just some text to fulfill the minimum requirement of 100 characters

$20 USD dalam sehari
(34 Ulasan)

3 pekerja bebas membida secara purata $28 untuk pekerjaan ini


Dear Client, Greetings!! We have few queries kindly ping us. Thanks for giving us the opportunity to bid over the requirement. As per your requirement, you would like to develop a Website. We would like to share Lagi

$25 USD dalam 10 hari
(21 Ulasan)

Hi there, I am a fulltime freelance web & mobile app developer. I got lot of experience on both web & mobile app development, Good with HTML, CSS, JS for frontend website Love coding with PHP and MySQL as datab Lagi

$40 USD dalam 7 hari
(0 Ulasan)