title: [go]Custom Server to handle request with specific path
body: <p>I want to make a api which handles the request which have the path such as 
  <code>http:\\localhost:8080\todo\something</code> but I need to do using custom server.</p>
  
  <p>Here is the piece of code I have written.</p>
  
  <pre><code>package main
  
  import (
          "net/http"
          "fmt"
          "io"
          "time"
      )
  
  
  func myHandler(w http.ResponseWriter, req *http.Request){
      io.WriteString(w, "hello, world!\n")
  }
  
  
  func main() {
  
      //Custom http server
      s := &amp;http.Server{
          Addr:           ":8080",
          Handler:        http.HandlerFunc(myHandler),
          ReadTimeout:    10 * time.Second,
          WriteTimeout:   10 * time.Second,
          MaxHeaderBytes: 1 &lt;&lt; 20,
      }
  
      err := s.ListenAndServe()
      if err != nil {
          fmt.Printf("Server failed: ", err.Error())
      }
  }
  </code></pre>
  
  <p>inspired by this <a href="https://stackoverflow.com/questions/25583028/how-to-write-a-simple-custom-http-server-in-go">post</a></p>
  
  <p>My handler accepts all the request such <code>http:localhost:8080\abc</code>, <code>http:localhost:8080\abc</code> etc
  How to give path in custom server so that it handles request only that matches the path.</p>