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.

Compétences : Golang, HTML, Javascript, PHP, Python

en voir plus : 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

Concernant l'employeur :
( 15 commentaires ) Pyeongtaeksi Gyeonggi-do, Korea, Republic of

Nº du projet : #17557110

Décerné à:


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

%selectedBids___i_sum_sub_4% %project_currencyDetails_sign_sub_5% USD en 1 jour
(34 Commentaires)

3 freelance font une offre moyenne de $28 pour ce travail


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 Plus

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 10 jours
(21 Commentaires)

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 Plus

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 7 jours
(0 Commentaires)