mirror of https://github.com/docker/docs.git
fix doc and empty content-type
This commit is contained in:
parent
4a1e0d321e
commit
954ecac388
32
api.go
32
api.go
|
@ -23,6 +23,14 @@ func hijackServer(w http.ResponseWriter) (io.ReadCloser, io.Writer, error) {
|
||||||
return conn, conn, nil
|
return conn, conn, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//If we don't do this, POST method without Content-type (even with empty body) will fail
|
||||||
|
func parseForm(r *http.Request) error {
|
||||||
|
if err := r.ParseForm(); err != nil && !strings.HasPrefix(err.Error(), "mime:") {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func httpError(w http.ResponseWriter, err error) {
|
func httpError(w http.ResponseWriter, err error) {
|
||||||
if strings.HasPrefix(err.Error(), "No such") {
|
if strings.HasPrefix(err.Error(), "No such") {
|
||||||
http.Error(w, err.Error(), http.StatusNotFound)
|
http.Error(w, err.Error(), http.StatusNotFound)
|
||||||
|
@ -109,7 +117,7 @@ func getContainersExport(srv *Server, w http.ResponseWriter, r *http.Request) ([
|
||||||
}
|
}
|
||||||
|
|
||||||
func getImages(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
func getImages(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
||||||
if err := r.ParseForm(); err != nil {
|
if err := parseForm(r); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +188,7 @@ func getContainersChanges(srv *Server, w http.ResponseWriter, r *http.Request) (
|
||||||
}
|
}
|
||||||
|
|
||||||
func getContainers(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
func getContainers(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
||||||
if err := r.ParseForm(); err != nil {
|
if err := parseForm(r); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
all := r.Form.Get("all") == "1"
|
all := r.Form.Get("all") == "1"
|
||||||
|
@ -202,7 +210,7 @@ func getContainers(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte,
|
||||||
}
|
}
|
||||||
|
|
||||||
func postImagesTag(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
func postImagesTag(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
||||||
if err := r.ParseForm(); err != nil {
|
if err := parseForm(r); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
repo := r.Form.Get("repo")
|
repo := r.Form.Get("repo")
|
||||||
|
@ -219,7 +227,7 @@ func postImagesTag(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte,
|
||||||
}
|
}
|
||||||
|
|
||||||
func postCommit(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
func postCommit(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
||||||
if err := r.ParseForm(); err != nil {
|
if err := parseForm(r); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var config Config
|
var config Config
|
||||||
|
@ -243,7 +251,7 @@ func postCommit(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, er
|
||||||
}
|
}
|
||||||
|
|
||||||
func postImages(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
func postImages(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
||||||
if err := r.ParseForm(); err != nil {
|
if err := parseForm(r); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +282,7 @@ func postImages(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, er
|
||||||
}
|
}
|
||||||
|
|
||||||
func getImagesSearch(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
func getImagesSearch(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
||||||
if err := r.ParseForm(); err != nil {
|
if err := parseForm(r); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +299,7 @@ func getImagesSearch(srv *Server, w http.ResponseWriter, r *http.Request) ([]byt
|
||||||
}
|
}
|
||||||
|
|
||||||
func postImagesInsert(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
func postImagesInsert(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
||||||
if err := r.ParseForm(); err != nil {
|
if err := parseForm(r); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,7 +322,7 @@ func postImagesInsert(srv *Server, w http.ResponseWriter, r *http.Request) ([]by
|
||||||
}
|
}
|
||||||
|
|
||||||
func postImagesPush(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
func postImagesPush(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
||||||
if err := r.ParseForm(); err != nil {
|
if err := parseForm(r); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,7 +383,7 @@ func postContainers(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func postContainersRestart(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
func postContainersRestart(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
||||||
if err := r.ParseForm(); err != nil {
|
if err := parseForm(r); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
t, err := strconv.Atoi(r.Form.Get("t"))
|
t, err := strconv.Atoi(r.Form.Get("t"))
|
||||||
|
@ -392,7 +400,7 @@ func postContainersRestart(srv *Server, w http.ResponseWriter, r *http.Request)
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteContainers(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
func deleteContainers(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
||||||
if err := r.ParseForm(); err != nil {
|
if err := parseForm(r); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
|
@ -427,7 +435,7 @@ func postContainersStart(srv *Server, w http.ResponseWriter, r *http.Request) ([
|
||||||
}
|
}
|
||||||
|
|
||||||
func postContainersStop(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
func postContainersStop(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
||||||
if err := r.ParseForm(); err != nil {
|
if err := parseForm(r); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
t, err := strconv.Atoi(r.Form.Get("t"))
|
t, err := strconv.Atoi(r.Form.Get("t"))
|
||||||
|
@ -459,7 +467,7 @@ func postContainersWait(srv *Server, w http.ResponseWriter, r *http.Request) ([]
|
||||||
}
|
}
|
||||||
|
|
||||||
func postContainersAttach(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
func postContainersAttach(srv *Server, w http.ResponseWriter, r *http.Request) ([]byte, error) {
|
||||||
if err := r.ParseForm(); err != nil {
|
if err := parseForm(r); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
logs := r.Form.Get("logs") == "1"
|
logs := r.Form.Get("logs") == "1"
|
||||||
|
|
|
@ -35,6 +35,7 @@ List containers
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
@ -89,7 +90,8 @@ Create a container
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
POST /containers HTTP/1.1
|
POST /containers HTTP/1.1
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"Hostname":"",
|
"Hostname":"",
|
||||||
"User":"",
|
"User":"",
|
||||||
|
@ -147,7 +149,8 @@ Inspect a container
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"Id": "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2",
|
"Id": "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2",
|
||||||
"Created": "2013-05-07T14:51:42.041847+02:00",
|
"Created": "2013-05-07T14:51:42.041847+02:00",
|
||||||
|
@ -218,6 +221,7 @@ Inspect changes on a container's filesystem
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
@ -258,7 +262,7 @@ Export a container
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
Content-Type: raw-stream-hijack
|
Content-Type: application/vnd.docker.raw-stream
|
||||||
|
|
||||||
{{ STREAM }}
|
{{ STREAM }}
|
||||||
|
|
||||||
|
@ -383,7 +387,7 @@ Attach to a container
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
Content-Type: raw-stream-hijack
|
Content-Type: application/vnd.docker.raw-stream
|
||||||
|
|
||||||
{{ STREAM }}
|
{{ STREAM }}
|
||||||
|
|
||||||
|
@ -415,6 +419,7 @@ Wait a container
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
{"StatusCode":0}
|
{"StatusCode":0}
|
||||||
|
|
||||||
|
@ -469,6 +474,7 @@ List Images
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
@ -509,7 +515,7 @@ Create an image
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
Content-Type: raw-stream-hijack
|
Content-Type: application/vnd.docker.raw-stream
|
||||||
|
|
||||||
{{ STREAM }}
|
{{ STREAM }}
|
||||||
|
|
||||||
|
@ -565,6 +571,7 @@ Inspect an image
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"id":"b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
|
"id":"b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
|
||||||
|
@ -616,6 +623,7 @@ Get the history of an image
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
@ -653,7 +661,7 @@ Push an image on the registry
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
Content-Type: raw-stream-hijack
|
Content-Type: application/vnd.docker.raw-stream
|
||||||
|
|
||||||
{{ STREAM }}
|
{{ STREAM }}
|
||||||
|
|
||||||
|
@ -729,6 +737,9 @@ Search images
|
||||||
**Example response**:
|
**Example response**:
|
||||||
|
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
|
HTTP/1.1 200 OK
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
@ -798,6 +809,7 @@ Get default username and email
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"username":"hannibal",
|
"username":"hannibal",
|
||||||
|
@ -820,6 +832,7 @@ Set auth configuration
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
POST /auth HTTP/1.1
|
POST /auth HTTP/1.1
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"username":"hannibal",
|
"username":"hannibal",
|
||||||
|
@ -855,6 +868,7 @@ Display system-wide information
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"Containers":11,
|
"Containers":11,
|
||||||
|
@ -885,6 +899,7 @@ Show the docker version information
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"Version":"0.2.2",
|
"Version":"0.2.2",
|
||||||
|
@ -915,7 +930,7 @@ Create a new image from a container's changes
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
Content-Type: raw-stream-hijack
|
Content-Type: application/vnd.docker.raw-stream
|
||||||
|
|
||||||
{{ STREAM }}
|
{{ STREAM }}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue