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.

Квалификация: Golang, HTML, Javascript, PHP, Python

Показать больше 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

О работодателе:
( 15 отзыв(-а, -ов) ) Pyeongtaeksi Gyeonggi-do, Korea, Republic of

ID проекта: #17557110



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

$20 USD за 1 день
(34 отзывов(-а))

3 фрилансеров(-а) в среднем готовы выполнить эту работу за $28


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 Больше

$25 USD за 10 дней(-я)
(21 отзывов(-а))

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 Больше

$40 USD за 7 дней(-я)
(0 отзывов(-а))